coremongo

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSession

func DeleteSession(hostName string) error

DeleteSession -DeleteSession

func GetDBInstance

func GetDBInstance(serverIPAddress, port, dbName string, timeOutInSeconds int) (*mongo.Database, error)

GetDBInstance - Gets database intance

func GetFileFromGridFS

func GetFileFromGridFS(db *mongo.Database, bucketName, fileName string) ([]byte, error)

GetFileFromGridFS - Gets file from gridfs

func GetMongoConnection

func GetMongoConnection(hostName string) (*mongo.Client, error)

GetMongoConnection method

func InitNewSession

func InitNewSession(hostDetails MongoHost) error

InitNewSession - InitNewSession

func InitUsingJSON

func InitUsingJSON(configs []MongoHost) error

InitUsingJSON initializes Mongo Connections for give JSON data

func SaveFileToGridFS

func SaveFileToGridFS(db *mongo.Database, bucketName, fileName string, source io.Reader) (string, string, error)

SaveFileToGridFS - Saves file to gridfs

Types

type MetaData added in v1.2.8

type MetaData struct {
	Findops   map[string]interface{}
	UpdateOps map[string]interface{}
}

type MongoDAO

type MongoDAO struct {
	MetaData MetaData
	// contains filtered or unexported fields
}

MongoDAO mongo DAO struct

func GetMongoDAO

func GetMongoDAO(collection string) *MongoDAO

GetMongoDAO return mongo DAO instance

func GetMongoDAOWithHost

func GetMongoDAOWithHost(host, collection string) *MongoDAO

GetMongoDAOWithHost return mongo DAO instance

func (*MongoDAO) BulkDeleteData

func (mg *MongoDAO) BulkDeleteData(data []interface{}) error

BulkDeleteData delete data in mongo db in bulk

func (*MongoDAO) BulkSaveData

func (mg *MongoDAO) BulkSaveData(data []interface{}) error

BulkSaveData ata Save data in mongo db in bulk

func (*MongoDAO) BulkUpdateData

func (mg *MongoDAO) BulkUpdateData(data []interface{}) error

BulkUpdateData update data in mongo db in bulk

func (*MongoDAO) BulkUpsertData

func (mg *MongoDAO) BulkUpsertData(data []interface{}) error

BulkUpsertData Upsert data in mongo db in bulk

func (*MongoDAO) CustomUpdate

func (mg *MongoDAO) CustomUpdate(selector map[string]interface{}, data interface{}) error

CustomUpdate - CustomUpdate

func (*MongoDAO) CustomUpdateOne

func (mg *MongoDAO) CustomUpdateOne(selector map[string]interface{}, data interface{}) error

CustomUpdateOne - CustomUpdateOne

func (*MongoDAO) DeleteAll

func (mg *MongoDAO) DeleteAll(selector map[string]interface{}) error

DeleteAll will delete all the matching data given for selector

func (*MongoDAO) DeleteData

func (mg *MongoDAO) DeleteData(selector map[string]interface{}) error

DeleteData will delete data given for selector

func (*MongoDAO) GetAggregateData

func (mg *MongoDAO) GetAggregateData(selector interface{}) (*gjson.Result, error)

GetAggregateData - return result using aggregation query

func (*MongoDAO) GetData

func (mg *MongoDAO) GetData(selector map[string]interface{}) (*gjson.Result, error)

GetData will return query for selector

func (*MongoDAO) GetProjectedData

func (mg *MongoDAO) GetProjectedData(selector map[string]interface{}, projector map[string]interface{}) (*gjson.Result, error)

GetProjectedData will return query for selector and projector

func (*MongoDAO) PushData

func (mg *MongoDAO) PushData(selector map[string]interface{}, data interface{}) error

PushData - append in array

func (*MongoDAO) SaveData

func (mg *MongoDAO) SaveData(data interface{}) (string, error)

SaveData Save data in mongo db

func (*MongoDAO) SetFindOps added in v1.2.8

func (mg *MongoDAO) SetFindOps(findOps map[string]interface{})

Set Find Options

func (*MongoDAO) SetUpdateOps added in v1.2.8

func (mg *MongoDAO) SetUpdateOps(updateOps map[string]interface{})

set update option for custom update

func (*MongoDAO) Update

func (mg *MongoDAO) Update(selector map[string]interface{}, data interface{}) error

Update will update single entry

func (*MongoDAO) UpdateAll

func (mg *MongoDAO) UpdateAll(selector map[string]interface{}, data interface{}) error

UpdateAll update all

func (*MongoDAO) Upsert

func (mg *MongoDAO) Upsert(selector map[string]interface{}, data interface{}) error

Upsert will update single entry

func (*MongoDAO) UpsertWithID added in v1.2.1

func (mg *MongoDAO) UpsertWithID(selector map[string]interface{}, data interface{}) (string, error)

UpsertWithID - will update or upsert a document in the collection

If a new document is upserted then it will return the ObjectID (string) of the upserted document.

If no document is upserted the object id returned will be empty string.

type MongoHost

type MongoHost struct {
	HostName        string        `json:"hostName"`
	Server          string        `json:"server"`
	Port            int           `json:"port"`
	Username        string        `json:"username"`
	Password        string        `json:"password"`
	Database        string        `json:"database"`
	IsDefault       bool          `json:"isDefault"`
	MaxIdleConns    int           `json:"maxIdleConns" `
	MaxOpenConns    int           `json:"maxOpenConns"`
	ConnMaxLifetime time.Duration `json:"connMaxLifetime" `
	IsDisabled      bool          `json:"isDisabled" `
}

MongoHost -MongoHost

Jump to

Keyboard shortcuts

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