Documentation ¶
Index ¶
- func Setup(dbConfig DbConfig) error
- type Db
- type DbConfig
- type DbSession
- func (s *DbSession) Clone() *DbSession
- func (s *DbSession) Close()
- func (s *DbSession) Exists(query Q, document Document) (bool, error)
- func (s *DbSession) Find(query Q, document Document) error
- func (s *DbSession) FindAll(query Q, document Document) (interface{}, error)
- func (s *DbSession) FindAllWithFields(query Q, fields []string, document Document) (interface{}, error)
- func (s *DbSession) FindByID(id string, result Document) error
- func (s *DbSession) FindByRef(ref *mgo.DBRef, document Document) error
- func (s *DbSession) FindWithLimit(limit int, query Q, document Document) (interface{}, error)
- func (s *DbSession) Pipe(pipeline interface{}, document Document) *mgo.Pipe
- func (s *DbSession) ReadFile(id, prefix string, file *File) error
- func (s *DbSession) Remove(query Q, document Document) error
- func (s *DbSession) RemoveAll(query Q, document Document) error
- func (s *DbSession) Save(document Document) error
- func (s *DbSession) SaveFile(file File, prefix string) (string, error)
- func (s *DbSession) Update(selector Q, document Document) error
- func (s *DbSession) UpdateFieldValue(query Q, collectionName, field string, value interface{}) error
- type Document
- type File
- type Q
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Db ¶
type Db struct { Config DbConfig // contains filtered or unexported fields }
Db represents database connection which holds reference to global session and configuration for that database.
type DbSession ¶
DbSession mgo session wrapper
func (*DbSession) Clone ¶
Clone returns the clone of current DB session. Cloned session uses the same socket connection
func (*DbSession) FindAllWithFields ¶
func (s *DbSession) FindAllWithFields(query Q, fields []string, document Document) (interface{}, error)
FindAllWithFields returns all the documents with given fields based on a given query
func (*DbSession) FindByID ¶
FindByID find the object by id. Returns error if it's not able to find the document. If document is found it's copied to the passed in result object.
func (*DbSession) FindWithLimit ¶
FindWithLimit find the doucments for given query with limit
func (*DbSession) Save ¶
Save inserts the given document that represents the collection to the database.
type Document ¶
type Document interface {
CollectionName() string
}
Document interface implemented by structs that needs to be persisted. It should provide collection name, as in the database. Also, a way to create new object id before saving.