db

package
v0.0.0-...-6abf10f Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseConnection

func CloseConnection()

CloseConnection Closes the client connection

func Ctx

func Ctx() context.Context

Ctx Returns the context

func DB

func DB() *mongo.Database

DB Returns the current active database

Types

type DeleteResponse

type DeleteResponse struct {
	Status bool `json:"status"`
	Length int  `json:"length"`
}

DeleteResponse Encapsulates the response of a Delete operation

type FindResponse

type FindResponse struct {
	Status bool                     `json:"status"`
	Length int                      `json:"length"`
	Items  []map[string]interface{} `json:"items"`
}

FindResponse Encapsulates the response of a Find operation

type InsertResponse

type InsertResponse struct {
	Status bool          `json:"status"`
	Length int           `json:"length"`
	Items  []interface{} `json:"items"`
}

InsertResponse Encapsulates the response of an Insert operation

type Item

type Item struct {
	CollectionName string
}

Item Encapsulates a collection

func (*Item) Collection

func (item *Item) Collection() *mongo.Collection

Collection Returns the collection associated to this class

func (*Item) Delete

func (item *Item) Delete(criteria map[string]interface{}) *DeleteResponse

Delete Deletes the given element from the current collection

func (*Item) Drop

func (item *Item) Drop()

Drop Drops the current collection

func (*Item) Find

func (item *Item) Find(criteria map[string]interface{}) *FindResponse

Find Find the items that fit the criteria

func (*Item) InsertMany

func (item *Item) InsertMany(elements []map[string]interface{}) InsertResponse

InsertMany Inserts multiple elements in the current collection

func (*Item) InsertOne

func (item *Item) InsertOne(element map[string]interface{}) *InsertResponse

InsertOne Inserts one element in the current collection

func (*Item) Update

func (item *Item) Update(criteria map[string]interface{}, updated map[string]interface{}) *UpdateResponse

Update Updates the given element with the new data in the current collection

type MongoEngine

type MongoEngine struct {
	Client   *mongo.Client
	Database string
	// contains filtered or unexported fields
}

MongoEngine Encapsulates a Mongo client with its database name

func GetEngine

func GetEngine() *MongoEngine

GetEngine Returns the only instance of MongoEngine

type UpdateResponse

type UpdateResponse struct {
	Status   bool `json:"status"`
	Modified int  `json:"modified"`
	Matched  int  `json:"matched"`
}

UpdateResponse Encapsulates the response of an Update operation

Jump to

Keyboard shortcuts

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