mongodb

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoClient

type MongoClient struct {
	*mongo.Client
	// contains filtered or unexported fields
}

MongoClient holds the connection to the database

func NewMongoClient

func NewMongoClient(dbName string, collections []string, opts *options.ClientOptions, searchIndices map[string](map[string]bool)) (*MongoClient, error)

NewMongoClient makes a connection with the mongo client

func (*MongoClient) Aggregate

func (c *MongoClient) Aggregate(collection string, pipeline mongo.Pipeline, object interface{}) error

Aggregate takes in a collection string, filter, pipeline, and pointer to object returns error if anything is malformed

func (*MongoClient) Close

func (m *MongoClient) Close(ctx context.Context) error

func (*MongoClient) Delete

func (c *MongoClient) Delete(collection string, filter *db.Filter) error

Delete deletes the certain document based on param and value

func (*MongoClient) Exists

func (c *MongoClient) Exists(collection string, filter interface{}) (bool, error)

Exists checks if the document exists within the collection based on the filter

func (*MongoClient) Find

func (c *MongoClient) Find(collection, param string, value interface{}, object interface{}) error

Find takes collection, param & value to build filter, and object pointer to receive data

func (*MongoClient) FindAll

func (m *MongoClient) FindAll(collection string, object interface{}, filter *db.Filter, opts *db.Options) error

FindAll finds all within the collection, using filter and options if applicable

func (*MongoClient) FindAllWithBSON

func (c *MongoClient) FindAllWithBSON(collection string, filter interface{}, opts *options.FindOptions, slice interface{}) error

FindAllWithBSON takes collection string, bson filter, options.FindOptions and decodes into pointer to the slice

func (*MongoClient) FindOne

func (m *MongoClient) FindOne(collection string, object interface{}, filter *db.Filter, opts *db.Options) error

func (*MongoClient) FindWithBSON

func (c *MongoClient) FindWithBSON(collection string, filter interface{}, opts *options.FindOneOptions, object interface{}) error

FindWithBSON takes in object and already made bson filter

func (*MongoClient) Insert

func (c *MongoClient) Insert(collection string, object interface{}) error

Insert takes a collection name and interface object and inserts into collection

func (*MongoClient) Open

func (m *MongoClient) Open(ctx context.Context) error

func (*MongoClient) Search

func (c *MongoClient) Search(collection, search string, fields []string, slice interface{}) error

Search takes a collection, search string, and slice of fields to search upon. The results are unmarshalled into slice interface

func (*MongoClient) Update

func (m *MongoClient) Update(collection string, object interface{}, filter *db.Filter) error

func (*MongoClient) UpdateWithBSON

func (c *MongoClient) UpdateWithBSON(collection string, filter, update interface{}) error

UpdateWithBSON takes in collection string & bson filter and update object

func (*MongoClient) Upsert

func (c *MongoClient) Upsert(collection string, object interface{}, filter *db.Filter) error

Upsert updates or inserts object within collection with premade filter

Jump to

Keyboard shortcuts

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