Documentation ¶
Index ¶
- func AddToArray(m collectionDatabaseNamer, filter bson.D, update bson.D, ...) (*mongo.UpdateResult, error)
- func Aggregate(m collectionDatabaseNamer, d mongo.Pipeline) (*mongo.Cursor, error)
- func Connect(connectionURI string, dbSigChan chan struct{}) error
- func CountDocuments(m collectionDatabaseNamer, filter bson.D) (int64, error)
- func DeleteAll(m collectionDatabaseNamer) error
- func DeleteMany(m collectionDatabaseNamer, d bson.D) error
- func DeleteOne(m collectionDatabaseNamer, d bson.D) error
- func Disconnect() error
- func Distinct(m collectionDatabaseNamer, field string, filter interface{}) ([]interface{}, error)
- func Find(m collectionDatabaseNamer, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func FindOne(m collectionDatabaseNamer, i interface{}, query bson.D, ...) (bool, error)
- func FindOneWithModel(m collectionDatabaseNamer, i interface{}, d bson.D) (interface{}, bool, error)
- func GetBsonAForArray(arrayData interface{}) (bson.A, error)
- func GetBsonDForStruct(structData interface{}) (bson.D, error)
- func GetClient() (*mongo.Client, error)
- func InsertMany(m collectionDatabaseNamer, docs []interface{}) ([]interface{}, error)
- func InsertOne(m collectionDatabaseNamer, i interface{}) (interface{}, error)
- func UpdateMany(m collectionDatabaseNamer, filter bson.D, update bson.D, ...) (*mongo.UpdateResult, error)
- func UpdateOne(m collectionDatabaseNamer, filter bson.D, update bson.D, ...) (*mongo.UpdateResult, error)
- func UpdateWithUnsetKey(m collectionDatabaseNamer, filter bson.D, update bson.D, ...) (*mongo.UpdateResult, error)
- type CollectionNamer
- type DatabaseNamer
- type JSONBodyDeserializer
- type JSONSerializer
- type UserGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddToArray ¶
func AddToArray(m collectionDatabaseNamer, filter bson.D, update bson.D, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func Connect ¶
Connect connects and sets a connection. More info on mongo connection string https://docs.mongodb.com/manual/reference/connection-string/
func DeleteMany ¶
DeleteMany delete many entries in a collection based on mongo query Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func DeleteOne ¶
DeleteOne delete one entry in a collection based on mongo query Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func Disconnect ¶
func Disconnect() error
Disconnect mongo client connection. Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func Find ¶
func Find(m collectionDatabaseNamer, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
func FindOne ¶
func FindOne(m collectionDatabaseNamer, i interface{}, query bson.D, opts ...*options.FindOneOptions) (bool, error)
FindOne finds one entry in a collection based on mongo query Returns myerrors.myerrors.ErrNoMongoConnection as error when no mongo connection
func FindOneWithModel ¶
func GetBsonAForArray ¶
func GetBsonDForStruct ¶
func GetClient ¶
GetClient returns the connected mongo client Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func InsertMany ¶
func InsertMany(m collectionDatabaseNamer, docs []interface{}) ([]interface{}, error)
InsertMany inserts many entry in a collection based on mongo query. Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func InsertOne ¶
func InsertOne(m collectionDatabaseNamer, i interface{}) (interface{}, error)
InsertOne inserts one entry in a collection based on mongo query. Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func UpdateMany ¶
func UpdateMany(m collectionDatabaseNamer, filter bson.D, update bson.D, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany finds all entry in a collection based on mongo query and updates it Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func UpdateOne ¶
func UpdateOne(m collectionDatabaseNamer, filter bson.D, update bson.D, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOne finds one entry in a collection based on mongo query and updates it Returns myerrors.ErrNoMongoConnection as error when no mongo connection
func UpdateWithUnsetKey ¶
func UpdateWithUnsetKey(m collectionDatabaseNamer, filter bson.D, update bson.D, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
Update with unset key removes the key and value on passing update-obj with bson.D{{"$unset", bson.D{{"<key>", ""}}}}
Types ¶
type CollectionNamer ¶
type CollectionNamer interface {
CollectionName() string
}
type DatabaseNamer ¶
type DatabaseNamer interface {
DatabaseName() string
}
type JSONBodyDeserializer ¶
type JSONBodyDeserializer interface {
DeserializeFromJSONInBody(r *http.Request) JSONBodyDeserializer
}
type JSONSerializer ¶
type JSONSerializer interface {
SerializeToJSON(w http.ResponseWriter) error
}