mongo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjectIDString added in v0.2.0

func GetObjectIDString(id interface{}) string

getObjectIDString

Types

type Mongodb

type Mongodb struct {
	Client *mongo.Client
	Config *connect.Config
}

Mongodb is mongo database's struct

func New

func New(config *connect.Config) *Mongodb

New create Mongodb struct instance

func (Mongodb) Close

func (mongodb Mongodb) Close(ctx context.Context) error

Close Db connect

func (Mongodb) Count added in v0.2.0

func (mongodb Mongodb) Count(ctx context.Context, collectionName string, filter interface{}, opts *easyOptions.CountOpts) (int64, error)

Count return int64,error

func (Mongodb) Delete

func (mongodb Mongodb) Delete(ctx context.Context, collectionName string, filter interface{}, opts *easyOptions.DeleteOpts) (*result.DeleteResult, error)

Delete at most one document from the collection. return DeleteResult,error

func (Mongodb) Deletes

func (mongodb Mongodb) Deletes(ctx context.Context, collectionName string, filter interface{}, opts *easyOptions.DeleteOpts) (*result.DeleteResult, error)

DeletesWithOptions return *result.DeleteResult,error

func (Mongodb) Find

func (mongodb Mongodb) Find(ctx context.Context, collectionName string, filter interface{}, opts *easyOptions.FindOpts) (*entity.Entity, error)

Find return Entity,error

func (Mongodb) Finds

func (mongodb Mongodb) Finds(ctx context.Context, collectionName string, filter interface{}, opts *easyOptions.FindOpts) ([]*entity.Entity, error)

Finds return []Entity,error

func (Mongodb) Insert

func (mongodb Mongodb) Insert(ctx context.Context, collectionName string, doc interface{}, opts *easyOptions.InsertOneOpts) (string, error)

Insert return (insert ID) string,error if error,return will be ""

func (Mongodb) Inserts

func (mongodb Mongodb) Inserts(ctx context.Context, collectionName string, docs []interface{}, opts *easyOptions.InsertOpts) ([]string, error)

Inserts return (insert IDs) []string,error

func (Mongodb) Update

func (mongodb Mongodb) Update(ctx context.Context, collectionName string, filter interface{}, update interface{}, opts *easyOptions.UpdateOpts) (*result.UpdateResult, error)

Update just update at most one document in the collection and return *result.UpdateResult,error

func (Mongodb) Updates

func (mongodb Mongodb) Updates(ctx context.Context, collectionName string, filter interface{}, update interface{}, opts *easyOptions.UpdateOpts) (*result.UpdateResult, error)

Updates return *result.UpdateResult,error

Jump to

Keyboard shortcuts

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