Documentation
¶
Index ¶
- Variables
- func CreateSession(client *mongo.Client) (mongo.Session, error)
- func CreateTransaction(client *mongo.Client, queries func(sc mongo.SessionContext) error) error
- func CreateTransactionOptions() *options.TransactionOptions
- func GetObjectIdFromString(id string) (*primitive.ObjectID, error)
- func NewCompoundFieldIndex(fieldIndexes []*FieldIndex, unique bool) *mongo.IndexModel
- func NewTTLIndex(fieldName string, expireAfterSeconds int32) *mongo.IndexModel
- func NewUniqueIndex(fieldIndex FieldIndex, unique bool) *mongo.IndexModel
- func PrepareFindOneAndUpdateOptions(projection interface{}, sort interface{}, upsert bool, ...) *options.FindOneAndUpdateOptions
- func PrepareFindOneOptions(projection interface{}, sort interface{}) *options.FindOneOptions
- func PrepareFindOptions(projection interface{}, sort interface{}, limit int64, skip int64) *options.FindOptions
- func PrepareUpdateOptions(upsert bool) *options.UpdateOptions
- type Collection
- type Config
- type ConnConfig
- type ConnHandler
- type DefaultConnHandler
- type FieldIndex
- type Order
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CreateSession ¶
CreateSession creates a new session
func CreateTransaction ¶
CreateTransaction creates a new transaction
func CreateTransactionOptions ¶
func CreateTransactionOptions() *options.TransactionOptions
CreateTransactionOptions creates the transaction options
func GetObjectIdFromString ¶
GetObjectIdFromString gets the object ID from the string
func NewCompoundFieldIndex ¶
func NewCompoundFieldIndex( fieldIndexes []*FieldIndex, unique bool, ) *mongo.IndexModel
NewCompoundFieldIndex creates a new compound field index model
func NewTTLIndex ¶
func NewTTLIndex(fieldName string, expireAfterSeconds int32) *mongo.IndexModel
NewTTLIndex creates a new TTL index model
func NewUniqueIndex ¶
func NewUniqueIndex(fieldIndex FieldIndex, unique bool) *mongo.IndexModel
NewUniqueIndex creates a new unique field index model
func PrepareFindOneAndUpdateOptions ¶ added in v0.2.0
func PrepareFindOneAndUpdateOptions( projection interface{}, sort interface{}, upsert bool, returnDocument options.ReturnDocument, ) *options.FindOneAndUpdateOptions
PrepareFindOneAndUpdateOptions prepares the find one and update options
func PrepareFindOneOptions ¶
func PrepareFindOneOptions(projection interface{}, sort interface{}) *options.FindOneOptions
PrepareFindOneOptions prepares the find one options
func PrepareFindOptions ¶
func PrepareFindOptions(projection interface{}, sort interface{}, limit int64, skip int64) *options.FindOptions
PrepareFindOptions prepares the find options
func PrepareUpdateOptions ¶
func PrepareUpdateOptions(upsert bool) *options.UpdateOptions
PrepareUpdateOptions prepares the update options
Types ¶
type Collection ¶
type Collection struct { Indexes *[]*mongo.IndexModel // contains filtered or unexported fields }
Collection represents a MongoDB collection
func NewCollection ¶
func NewCollection( name string, indexes *[]*mongo.IndexModel, ) *Collection
NewCollection creates a new MongoDB collection
func (*Collection) CreateCollection ¶
func (c *Collection) CreateCollection(database *mongo.Database) ( collection *mongo.Collection, err error, )
CreateCollection creates the collection
type ConnConfig ¶ added in v0.5.0
type ConnConfig struct {
// contains filtered or unexported fields
}
ConnConfig struct
func NewConnConfig ¶ added in v0.5.0
func NewConnConfig(uri string, timeout time.Duration) *ConnConfig
NewConnConfig creates a new MongoDB connection configuration
func (*ConnConfig) Timeout ¶ added in v0.5.0
func (c *ConnConfig) Timeout() time.Duration
Timeout returns the MongoDB connection timeout
func (*ConnConfig) URI ¶ added in v0.5.0
func (c *ConnConfig) URI() string
URI returns the MongoDB URI
type ConnHandler ¶ added in v0.5.0
type ConnHandler interface { Connect() (*mongo.Client, error) Client() (*mongo.Client, error) Disconnect() }
ConnHandler interface
type DefaultConnHandler ¶ added in v0.5.0
type DefaultConnHandler struct {
// contains filtered or unexported fields
}
DefaultConnHandler struct
func NewDefaultConnHandler ¶ added in v0.5.0
func NewDefaultConnHandler(config Config) ( *DefaultConnHandler, error, )
NewDefaultConnHandler creates a new connection
func (*DefaultConnHandler) Client ¶ added in v0.5.0
func (d *DefaultConnHandler) Client() (*mongo.Client, error)
Client returns the MongoDB client
func (*DefaultConnHandler) Connect ¶ added in v0.5.0
func (d *DefaultConnHandler) Connect() (*mongo.Client, error)
Connect returns a new MongoDB client
func (*DefaultConnHandler) Disconnect ¶ added in v0.5.0
func (d *DefaultConnHandler) Disconnect()
Disconnect closes the MongoDB client connection
type FieldIndex ¶
type FieldIndex struct {
// contains filtered or unexported fields
}
func NewFieldIndex ¶
func NewFieldIndex(name string, order Order) *FieldIndex
NewFieldIndex creates a new field index