mongodb

package
v0.0.0-...-6c9b1ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

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 Aggregate

func Aggregate(m collectionDatabaseNamer, d mongo.Pipeline) (*mongo.Cursor, error)

func Connect

func Connect(connectionURI string, dbSigChan chan struct{}) error

Connect connects and sets a connection. More info on mongo connection string https://docs.mongodb.com/manual/reference/connection-string/

func CountDocuments

func CountDocuments(m collectionDatabaseNamer, filter bson.D) (int64, error)

func DeleteAll

func DeleteAll(m collectionDatabaseNamer) error

func DeleteMany

func DeleteMany(m collectionDatabaseNamer, d bson.D) error

DeleteMany delete many entries in a collection based on mongo query Returns myerrors.ErrNoMongoConnection as error when no mongo connection

func DeleteOne

func DeleteOne(m collectionDatabaseNamer, d bson.D) error

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 Distinct

func Distinct(m collectionDatabaseNamer, field string, filter interface{}) ([]interface{}, error)

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 FindOneWithModel(m collectionDatabaseNamer, i interface{}, d bson.D) (interface{}, bool, error)

func GetBsonAForArray

func GetBsonAForArray(arrayData interface{}) (bson.A, error)

func GetBsonDForStruct

func GetBsonDForStruct(structData interface{}) (bson.D, error)

func GetClient

func GetClient() (*mongo.Client, error)

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
}

type UserGroup

type UserGroup struct {
	DatabaseNamer
}

func (UserGroup) DatabaseName

func (a UserGroup) DatabaseName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL