mongo

package module
v0.0.0-...-3772a09 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

mongo

Helpers for mongo db

Documentation

Overview

package mongo implements CRUD system with mongoDB NOTE: passing nil as the filter matches all documents in the collection

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseClient

func CloseClient(ctx context.Context) error

CloseClient checks if mongodb client if pingable and disconnects from database

func CreateMongoClient

func CreateMongoClient(uri, port string) (*mongo.Client, error)

CreateClient creates client for mongodb server on uri+port and returns a pointer and an error

func DeleteOne

func DeleteOne(c *mongo.Collection, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func Find

func Find(c *mongo.Collection, filter, results []interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

Find finds all documents that match filter and returns error result is a pointer

func FindOne

func FindOne(c *mongo.Collection, filter, result interface{}, opts ...*options.FindOneOptions) error

FindOne finds single value in the database and returns error result is a pointer

func GetCollection

func GetCollection(database, collectionName string) *mongo.Collection

GetCollection gets collection with a collectionName from database

func InsertMany

func InsertMany(c *mongo.Collection, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func InsertOne

func InsertOne(c *mongo.Collection, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func UpdateOne

func UpdateOne(c *mongo.Collection, filter, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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