mongoose

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ShortWaitTime  time.Duration = 2
	MediumWaitTime time.Duration = 5
	LongWaitTime   time.Duration = 10
)

ShortWaitTime Small Wait time MediumWaitTime Medium Wait Time LongWaitTime Long wait time

Functions

func DeleteOne

func DeleteOne(filter bson.M, tempCollection interface{}) (*mongo.DeleteResult, error)

DeleteOne Deletes one Object

func FindAll

func FindAll(filter bson.M, modelsOutArrayPtr interface{}) error

FindAll Get All Docs

func FindAllWithOptions added in v1.0.7

func FindAllWithOptions(filter bson.M, option options.FindOptions, modelsOutArrayPtr interface{}) error

FindAllWithOptions Find all with options

func FindAllWithPagination added in v1.0.6

func FindAllWithPagination(filter bson.M, start int64, count int64, modelsOutArrayPtr interface{}) error

FindAllWithPagination Get All Docs with Pagination

func FindByID

func FindByID(id string, b interface{}) (err error)

FindByID Searches by ID

func FindByObjectID

func FindByObjectID(objectID primitive.ObjectID, bPtr interface{}) (err error)

FindByObjectID Searches by Object ID

func FindOne

func FindOne(filter bson.M, b interface{}) (err error)

FindOne Searches one object and returns its value

func InitiateDB added in v1.0.4

func InitiateDB(dbConnection DBConnection)

InitiateDB This needs to be called if you are using some other than default DB

func InsertMany

func InsertMany(models []interface{}) (res *mongo.InsertManyResult, err error)

InsertMany This will insert multiple Data TODO Find a way to pass pointer and attach its ID to the respective array elements

func InsertOne

func InsertOne(modelPtr interface{}) (res *mongo.InsertOneResult, err error)

InsertOne This will insert just one Data

func PopulateObject added in v1.0.4

func PopulateObject(objPtr interface{}, fieldName string, modelPtr interface{})

PopulateObject an Object

func PopulateObjectArray added in v1.0.4

func PopulateObjectArray(obj interface{}, field string, modelArrPtr interface{}) error

PopulateObjectArray Populates the Object Array

func UpdateByID

func UpdateByID(model interface{}) error

UpdateByID Updates by ID

Types

type DBConnection added in v1.0.4

type DBConnection struct {
	Host     string
	Port     int
	Database string
	User     string
	Password string
}

DBConnection DB Connection Details

type Mongo

type Mongo struct {
	Database *mongo.Database
	Err      error
	// contains filtered or unexported fields
}

Mongo This is the Mongo struct

func Get

func Get() Mongo

Get This function will recieve the Mongo structure

Jump to

Keyboard shortcuts

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