mongo

package module
v0.0.0-...-69072d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2017 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigFile = "mongodb.cfg"

ConfigFile defines configuration file's name.

Variables

This section is empty.

Functions

func AllEntities

func AllEntities(tableName string, list interface{}) error

AllEntities returns an entity collection sort by id.

func AllEntitiesWithCriteria

func AllEntitiesWithCriteria(tableName string, criterion bson.M, list interface{}) error

AllEntitiesWithCriteria returns an entity collection base on criterion sort by id.

func AllEntitiesWithCriteriaAndSortDescriptions

func AllEntitiesWithCriteriaAndSortDescriptions(tableName string, criterion bson.M, sortDescriptions []string, list interface{}) error

AllEntitiesWithCriteriaAndSortDescriptions returns an entity collection base on criterion sort by id.

func AllEntitiesWithSortDescriptions

func AllEntitiesWithSortDescriptions(tableName string, sortDescriptions []string, list interface{}) error

AllEntitiesWithSortDescriptions returns an entity collection sort by defined.

func ConnectMongo

func ConnectMongo()

ConnectMongo creates session.

func Count

func Count(tableName string) (int, error)

Count returns number of entities.

func CreateConfigs

func CreateConfigs()

CreateConfigs generates a default configuration file.

func DeleteEntity

func DeleteEntity(tableName string, entityID bson.ObjectId) error

DeleteEntity deletes a record from collection.

func DeleteEntityWithCriteria

func DeleteEntityWithCriteria(tableName string, criterion bson.M) error

DeleteEntityWithCriteria deletes a record from collection with creteria.

func EntityWithCriteria

func EntityWithCriteria(tableName string, criterion bson.M, entity interface{}) error

EntityWithCriteria finds entity with creteria.

func EntityWithID

func EntityWithID(tableName string, entityID bson.ObjectId, entity interface{}) error

EntityWithID finds entity with ID.

func GetEventualSession

func GetEventualSession() (*mgo.Session, *mgo.Database)

GetEventualSession clones session with eventual mode.

func GetMonotonicSession

func GetMonotonicSession() (*mgo.Session, *mgo.Database)

GetMonotonicSession clones session with monotonic mode.

func GetStrongSession

func GetStrongSession() (*mgo.Session, *mgo.Database)

GetStrongSession clones session with strong mode.

func SaveEntity

func SaveEntity(tableName string, entityID bson.ObjectId, entity interface{}) error

SaveEntity inserts/updates an entity.

Types

type Config

type Config struct {
	Addresses []string `json:"addresses"`
	Database  string   `json:"database"`
	Username  string   `json:"username"`
	Password  string   `json:"password"`
}

Config descripts a configuration object that will be used during application life time.

func LoadConfigs

func LoadConfigs() *Config

LoadConfigs retrieves previous configuration from file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL