mongo

package
v0.0.0-...-0626e7f Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleEquals

func HandleEquals(pipeline *[]bson.M, fieldName string, fieldValue interface{})

Parse the == into equivalent mongo query.

func HandleGreaterThan

func HandleGreaterThan(pipeline *[]bson.M, fieldName string, fieldValue interface{})

Parse the > into equivalent mongo query.

func HandleGreaterThanEquals

func HandleGreaterThanEquals(pipeline *[]bson.M, fieldName string, fieldValue interface{})

Parse the >= into equivalent mongo query.

func HandleLessThan

func HandleLessThan(pipeline *[]bson.M, fieldName string, fieldValue interface{})

Parse the < into equivalent mongo query.

func HandleLessThanEquals

func HandleLessThanEquals(pipeline *[]bson.M, fieldName string, fieldValue interface{})

Parse the <= into equivalent mongo query.

func HandleNotEquals

func HandleNotEquals(pipeline *[]bson.M, fieldName string, fieldValue interface{})

Parse the != into equivalent mongo query.

Types

type DBClient

type DBClient interface {
	QueryMongo(pipeline []Queries) (Result, error)
	GetAllDataFromMongo() []EmployeeDetails
}

type EmployeeDetails

type EmployeeDetails struct {
	Name        string
	Designation string
	Salary      int64
	Email       string
	Mobile      string
	Manager     string
}

type MockMongoClient

type MockMongoClient interface {
	QueryMongo(pipeline []Queries) (Result, error)
	GetAllDataFromMongo() []EmployeeDetails
}

func NewMockMongoClient

func NewMockMongoClient(mongo *mongo.Client, database string) MockMongoClient

type MockMongoClientStruct

type MockMongoClientStruct struct {
	Mongo         *mongo.Client
	Database      string
	ClientOptions *options.ClientOptions
	Logger        *zap.Logger
}

func (*MockMongoClientStruct) GetAllDataFromMongo

func (c *MockMongoClientStruct) GetAllDataFromMongo() []EmployeeDetails

func (*MockMongoClientStruct) QueryMongo

func (c *MockMongoClientStruct) QueryMongo(pipeline []Queries) (Result, error)

type Mongo

type Mongo struct {
	Mongo         *mongo.Client
	Database      string
	ClientOptions *options.ClientOptions
	Logger        *zap.Logger
}

func (*Mongo) CreateConnection

func (c *Mongo) CreateConnection() (*mongo.Client, error)

Create a connection with mongo DB.

func (*Mongo) CreateTestData

func (c *Mongo) CreateTestData()

func (*Mongo) GetAllDataFromMongo

func (c *Mongo) GetAllDataFromMongo() []EmployeeDetails

Fetches all the employees data from mongo DB.

func (*Mongo) QueryMongo

func (c *Mongo) QueryMongo(pipeline []Queries) (Result, error)

Queries the mongo DB

type Queries

type Queries struct {
	Pipeline bson.M
}

type Result

type Result struct {
	Defined bool
	Data    []EmployeeDetails
}

Result contains output of partially evaluating a query.

Jump to

Keyboard shortcuts

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