db

package
v0.0.0-...-4ab0fb9 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(mongoURI string)

Init sets default URI for mongo

Types

type Client

type Client struct {
	Mutex  sync.Mutex
	Client *mongo.Client
}

Client has Mutex to provide access for multiple goroutines

var (
	DefaultClient *Client
)

func NewClient

func NewClient() *Client

NewClient returns new client, connected to database

func (*Client) DeleteMany

func (d *Client) DeleteMany(filter interface{}, db, collection string) error

DeleteMany deletes many items

func (*Client) DeleteOne

func (d *Client) DeleteOne(filter interface{}, db, collection string) error

DeleteOne deletes one item

func (*Client) FindMany

func (d *Client) FindMany(filter interface{}, db, collection string) (*mongo.Cursor, error)

FindMany finds many entries

func (*Client) FindOne

func (d *Client) FindOne(filter interface{}, toDecode interface{}, db, collection string) error

FindOne finds data and decodes to the given pointer

func (*Client) InsertMany

func (d *Client) InsertMany(data []interface{}, db, collection string) error

InsertMany inserts multiple values

func (*Client) InsertOne

func (d *Client) InsertOne(data interface{}, db, collection string) error

InsertOne just inserts one value

func (*Client) UpdateOne

func (d *Client) UpdateOne(filter interface{}, update interface{}, db, collection string) error

UpdateOne just updates one item by given filter

Jump to

Keyboard shortcuts

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