Documentation ¶
Index ¶
- func C(collectionName string) *mongo.Collection
- func CollectionWithDB(db, coll string) *mongo.Collection
- func Connect(gtx context.Context, opts *ConnOpts) error
- func Decode(res *mongo.SingleResult, out interface{}) error
- func GenerateSelector(filter *teak.Filter) (selector bson.M)
- func GetSort(sortField string) bson.D
- func NewDefaultApp(name string, appVersion teak.Version, apiVersion int, desc string) *teak.App
- func NewStorage() teak.DataStorage
- func NewUserStorage() teak.UserStorage
- func ReadAllAndClose(gtx context.Context, cur *mongo.Cursor, out interface{}) error
- func ReadOneAndClose(gtx context.Context, cur *mongo.Cursor, out interface{}) error
- func SetDefaultDB(defDB string)
- type ConnOpts
- type ConnType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func C ¶
func C(collectionName string) *mongo.Collection
C - get a handle to collection in the default database, single letter name to have nice way to transition from mgo
func CollectionWithDB ¶
func CollectionWithDB(db, coll string) *mongo.Collection
CollectionWithDB - gives a reference to a collection in given database
func Connect ¶
Connect - connects to a mongoDB instance or a cluster based on the the options provided
func Decode ¶
func Decode(res *mongo.SingleResult, out interface{}) error
Decode - convenience method for decoding mongo.SingleResult
func GenerateSelector ¶
GenerateSelector - creates mongodb query for a generic filter
func NewDefaultApp ¶
NewDefaultApp - creates a new app with MongoDB based storage providers
func NewStorage ¶
func NewStorage() teak.DataStorage
NewStorage - creates a new mongodb based data storage implementation
func NewUserStorage ¶
func NewUserStorage() teak.UserStorage
NewUserStorage - creates a new user storage based on mongodb
func ReadAllAndClose ¶
ReadAllAndClose - reads all data from the cursor and closes it
func ReadOneAndClose ¶
ReadOneAndClose - reads one data item from the cursor and closes it