database

package
v0.0.157 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Delete added in v0.0.157

func Delete[T any](collection string, id primitive.ObjectID) (bool, error)

func Get

func Get[T any](collection string, id primitive.ObjectID) (*T, error)

func Insert added in v0.0.157

func Insert[T any](collection string, doc T) (primitive.ObjectID, error)

func Query

func Query[T any](collection string, filter bson.D, sort bson.D, projection bson.D, start int64, limit int) ([]*T, error)

Query the database for multiple documents.

@Param collection The name of the collection to query.

@Param filter A BSON document specifying a filter to apply to the query.

@Param sort A BSON document specifying how to sort the returned results.

{'field': order}
where 'field' is the name of the field in the database, and <order> is an integer value specifying
whether the field should be sorted ascending (1) or descending (-1)

@Param projection A BSON document specifying a specific set of fields to return or ignore

{'field': value}
where 'field' is the name of the field in the database, and <value> is an integer value specifying
whether the field should be returned (1, excluding others) or ignored (0)

@Param start The starting document for the query results.

@Param limit The maximum number of documents to return in the query.

@Return An array of the documents matching the query parameters, or an error.

func SetupDatabase

func SetupDatabase()

func TeardownDatabase

func TeardownDatabase()

func Update added in v0.0.157

func Update[T any](collection string, id primitive.ObjectID, doc T) (int, int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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