database

package module
v0.0.0-...-5e5b930 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 7 Imported by: 0

README

go-mongo-wrapper

My personal MongoDB access wrapper for when I'm working in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIndex

func AddIndex(collection *mgm.Collection, config IndexKey) (string, error)

func AddIndexes

func AddIndexes(collection *mgm.Collection, fields []IndexKey) ([]string, error)

func Collection

func Collection(collection mgm.Model) *mgm.Collection

func Delete

func Delete(collection *mgm.Collection, object mgm.Model) error

func Find

func Find(collection *mgm.Collection, result interface{}, filter bson.M, findOptions *options.FindOptions) error

func FindByID

func FindByID(id string, collection *mgm.Collection, obj mgm.Model) error

func First

func First(collection *mgm.Collection, object mgm.Model, filter bson.M) error

func InitialiseDatabase

func InitialiseDatabase(dbName string, mongoURI string)

func InsertOne

func InsertOne(collection *mgm.Collection, object mgm.Model) error

func Replace

func Replace(collection *mgm.Collection, object mgm.Model) error

Types

type IndexKey

type IndexKey struct {
	Field     string
	Ascending bool
	Unique    bool
}

Jump to

Keyboard shortcuts

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