db

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Connected bool
	Database  string
	// contains filtered or unexported fields
}

Client database

func New

func New(database string) *Client

New creates a new Client object

func (*Client) C

func (dba *Client) C(coll string) *mongo.Collection

C opens a given collection in the xdcc database

func (*Client) Close

func (dba *Client) Close() error

Close connection

func (*Client) Connect

func (dba *Client) Connect(host string)

Connect Connects to the xdcc database

func (*Client) Delete

func (dba *Client) Delete(coll string, key string, value string) (*mongo.DeleteResult, error)

Delete returns all entities of a given collection

func (*Client) DeleteAll

func (dba *Client) DeleteAll(coll string) (*mongo.DeleteResult, error)

DeleteAll returns all entities of a given collection

func (*Client) DeleteByID

func (dba *Client) DeleteByID(coll string, id string) (*mongo.DeleteResult, error)

DeleteByID returns all entities of a given collection

func (*Client) Drop

func (dba *Client) Drop(coll string) error

Drop drops the collection

func (*Client) Find

func (dba *Client) Find(coll string, key string, value string) (*mongo.Cursor, error)

Find returns all entities of a given collection

func (*Client) FindAll

func (dba *Client) FindAll(coll string) (*mongo.Cursor, error)

FindAll returns all entities of a given collection

func (*Client) FindAllWithParams

func (dba *Client) FindAllWithParams(coll string, params *QueryParams) (*mongo.Cursor, error)

FindAllWithParams returns all entities of a given collection

func (*Client) FindByID

func (dba *Client) FindByID(coll string, id string) *mongo.SingleResult

FindByID returns all entities of a given collection

func (*Client) FindOne

func (dba *Client) FindOne(coll string, key string, value string) *mongo.SingleResult

FindOne returns all entities of a given collection

func (*Client) InsertOne

func (dba *Client) InsertOne(coll string, data interface{}) (*mongo.InsertOneResult, error)

InsertOne inserts one document

func (*Client) UpdateOne

func (dba *Client) UpdateOne(coll string, key string, value string, data interface{}) (*mongo.UpdateResult, error)

UpdateOne inserts one document

func (*Client) UpdateOneByID

func (dba *Client) UpdateOneByID(coll string, id string, data interface{}) (*mongo.UpdateResult, error)

UpdateOneByID inserts one document

type QueryParam

type QueryParam struct {
	Key   string
	Value interface{}
}

QueryParam ...

type QueryParams

type QueryParams struct {
	// contains filtered or unexported fields
}

QueryParams ...

func NewQueryParams

func NewQueryParams(queryParams ...QueryParam) *QueryParams

NewQueryParams ...

func (QueryParams) AsBSON

func (qp QueryParams) AsBSON() bson.M

AsBSON ...

func (*QueryParams) With

func (qp *QueryParams) With(param QueryParam) *QueryParams

With ...

Jump to

Keyboard shortcuts

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