Documentation ¶
Index ¶
- Variables
- type Config
- type Handler
- func (ms *Handler) Delete(collectionName string, query interface{}) error
- func (ms *Handler) Find(collectionName string, query, selectFields interface{}, sort []string, ...) ([]map[string]interface{}, error)
- func (ms *Handler) FindOne(collectionName string, query, selectFields interface{}, sort []string, ...) (map[string]interface{}, error)
- func (ms *Handler) InsertInfo(collectionName string, data interface{}) (string, error)
- func (ms *Handler) Update(collectionName string, query, data interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when the document was not found in Mongo collection ErrNotFound = errors.New("Document not found") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { AppName string `json:"appName,omitempty"` Name string `json:"name,omitempty"` Host []string `json:"host,omitempty"` Port string `json:"port,omitempty"` ConnectionString string `json:"connectionString,omitempty"` AuthSource string `json:"authSource,omitempty"` ReplicaSet string `json:"replicaSet,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Direct bool `json:"direct,omitempty"` Timeout time.Duration `json:"timeout,omitempty"` ReadPreference mgo.ReadPreference `json:"readPreference,omitempty"` }
Config holds the config required for MongoDB
type Handler ¶
type Handler struct { DBName string // contains filtered or unexported fields }
Handler DB Sessions are maintained inside a struct for better caching of the data stores developed based on the stackoverflow answer: http://stackoverflow.com/questions/26574594/best-practice-to-maintain-a-mgo-session
func (*Handler) Find ¶
func (ms *Handler) Find(collectionName string, query, selectFields interface{}, sort []string, start, limit int, result interface{}) ([]map[string]interface{}, error)
Find finds all records matching the query
func (*Handler) FindOne ¶
func (ms *Handler) FindOne(collectionName string, query, selectFields interface{}, sort []string, result interface{}) (map[string]interface{}, error)
FindOne finds and returns the first matching document based on the provided query
func (*Handler) InsertInfo ¶
InsertInfo inserts a new document and return inserted document's ID
Click to show internal directories.
Click to hide internal directories.