mongo

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2020 License: MIT Imports: 7 Imported by: 0

README

mongo

Go abstraction of the official MongoDB driver

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSOND

type BSOND = bson.D

BSOND - bson.D reference

type Client

type Client struct {
	DB *mongo.Database
}

Client - client object

func Create

func Create(co ClientOptions) (Client, error)

Create - Create mongo client using the client options

func (*Client) DeleteMany

func (clnt *Client) DeleteMany(coll string, filter bson.D) int64

DeleteMany - Delete one or many objects

func (*Client) Find

func (clnt *Client) Find(coll string, query interface{}) []*mongo.Cursor

Find - find many documents

func (*Client) FindOne

func (clnt *Client) FindOne(coll string, query interface{}) *mongo.SingleResult

FindOne - Find one document

func (*Client) FindOneAndUpdate

func (clnt *Client) FindOneAndUpdate(coll string, query bson.D, doc *primitive.D) *mongo.SingleResult

FindOneAndUpdate - Update one document

func (*Client) Save

func (clnt *Client) Save(coll string, model interface{}) *mongo.InsertOneResult

Save - Save a document to mongoDB

func (*Client) ToBsonDoc

func (clnt *Client) ToBsonDoc(v interface{}) (doc *bson.D, err error)

ToBsonDoc - Helper fuction that converts struct to byson for filters and queries

type ClientOptions

type ClientOptions struct {
	URI    string
	DBName string
}

ClientOptions - connection settings and options for mongoDB

type ObjectID

type ObjectID = primitive.ObjectID

ObjectID - primitive reference

Jump to

Keyboard shortcuts

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