mongoose

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 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 DeleteMany added in v0.0.3

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

DeleteMany Deletes Many Objects

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

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

FindAllWithOptions Find all with options

func FindAllWithPagination

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

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

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

PopulateObject an Object

func PopulateObjectArray

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

PopulateObjectArray Populates the Object Array

func TestConnection added in v0.0.7

func TestConnection() error

func UpdateByID

func UpdateByID(model interface{}) error

UpdateByID Updates by ID

func UpdateDataByID added in v0.0.2

func UpdateDataByID(model interface{}, update interface{}) error

Types

type DBConnection

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

	ConnectionURL string

	SRV bool
}

DBConnection DB Connection Details

func (*DBConnection) BuildConnectionURL added in v0.0.7

func (dbConnection *DBConnection) BuildConnectionURL()

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, error)

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