mongo

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectionCount

func CollectionCount(c string, filters interface{}, opts ...*options.CountOptions) (string, int64)

CollectionCount return how many documents in the collection.

func CollectionDocuments

func CollectionDocuments(c string, Skip, Limit int64, sort, filter interface{}) *mongo.Cursor

CollectionDocuments returns many documents matching the given filter and other criteria options in the collection. sort 1 ascending and -1 descending.

func CreateTTLIndex

func CreateTTLIndex(c string, expireAfterSeconds int32) (string, error)

CreateTTLIndex Create TTL Index for specified collection. returns the index name and error if it occurs.

func Delete

func Delete(c string, key string, document interface{}) int64

Delete deletes a single document.

func DeleteAll

func DeleteAll(c string, filter interface{}) int64

DeleteAll deletes all documents

func Find

func Find(c string, key string, document interface{}) *mongo.SingleResult

Find returns a document matching the given filter in the collection.

func FindAll

func FindAll(c string, filter interface{}) (*mongo.Cursor, error)

FindAll returns many documents matching the filter in the collection.

func FindOneAndUpdate

func FindOneAndUpdate(c string, filter interface{}, document interface{}) *mongo.SingleResult

FindOneAndUpdate updates a single document based on the filter with the document.

func FindWithOptions

func FindWithOptions(c string, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

FindWithOptions returns matched documents with find options.

func Replace

func Replace(c string, filter, documents interface{}) int64

Replace replace a document with a new one

func Save

func Save(c string, document interface{}) *mongo.InsertOneResult

Save saves one object to the database.

func SaveAll

func SaveAll(c string, documents []interface{}) *mongo.InsertManyResult

SaveAll save many objects to the database.

func Sum

func Sum(c string, pipeline string) ([]bson.M, error)

Sum returns the sum of all the accounts for given key.

func Update

func Update(c string, filter, document interface{}) int64

Update update or insert document.

func UpdateAll

func UpdateAll(c string, filter, documents interface{}) int64

UpdateAll update all documents in the collection

Types

type Matchby

type Matchby struct {
	Key   string
	Value string
}

Matchby represents the options for a matching.

Jump to

Keyboard shortcuts

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