mgo

package module
v0.0.0-...-e830b44 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: LGPL-3.0 Imports: 8 Imported by: 0

README

mgo

mongodb lib

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HexToObjectID

func HexToObjectID(vid []string) []primitive.ObjectID

HexToObjectID ...

Types

type Client

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

Client ...

func New

func New(uri string, timeout ...time.Duration) (*Client, error)

New opens new connection to mongo server

func (*Client) Database

func (c *Client) Database(s string, opts ...*options.DatabaseOptions) *DB

Database ...

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect ...

func (*Client) Ping

func (c *Client) Ping() error

Ping ...

type Collection

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

Collection ...

func (*Collection) CountDocuments

func (c *Collection) CountDocuments(filter interface{}, opts ...*options.CountOptions) (int64, error)

CountDocuments ...

func (*Collection) DeleteMany

func (c *Collection) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteMany deletes multiple documents from the collection.

func (*Collection) DeleteOne

func (c *Collection) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteOne deletes a single document from the collection.

func (*Collection) Duplicate

func (c *Collection) Duplicate() (*Client, *Collection, error)

Duplicate ...

func (*Collection) EstimatedDocumentCount

func (c *Collection) EstimatedDocumentCount(opts ...*options.EstimatedDocumentCountOptions) (int64, error)

EstimatedDocumentCount ...

func (*Collection) Find

func (c *Collection) Find(filter interface{}, opts ...*options.FindOptions) (*Cursor, error)

Find then finds the documents matching a model.

func (*Collection) FindEx

func (c *Collection) FindEx(filter interface{}, opts ...*options.FindOptions) (*Cursor, error)

FindEx duplicates and then finds the documents matching a model.

func (*Collection) FindOne

func (c *Collection) FindOne(filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

FindOne returns up to one document that matches the model.

func (*Collection) FindOneAndDelete

func (c *Collection) FindOneAndDelete(filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult

FindOneAndDelete find a single document and deletes it, returning the original in result.

func (*Collection) FindOneAndUpdate

func (c *Collection) FindOneAndUpdate(filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult

FindOneAndUpdate finds a single document and updates it, returning either the original or the updated.

func (*Collection) GetAll

func (c *Collection) GetAll(x interface{}) error

GetAll ...

func (*Collection) Indexes

func (c *Collection) Indexes(models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)

Indexes ..

func (*Collection) InsertMany

func (c *Collection) InsertMany(documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

InsertMany inserts the provided documents.

func (*Collection) InsertOne

func (c *Collection) InsertOne(document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

InsertOne inserts a single document into the collection.

func (*Collection) ReplaceOne

func (c *Collection) ReplaceOne(filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

ReplaceOne replaces a single document in the collection.

func (*Collection) Transaction

func (c *Collection) Transaction(cb TransactionCallback) error

Transaction ...

func (*Collection) UpdateMany

func (c *Collection) UpdateMany(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateMany updates multiple documents in the collection.

func (*Collection) UpdateOne

func (c *Collection) UpdateOne(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateOne updates a single document in the collection.

type Cursor

type Cursor struct {
	*mongo.Cursor
}

Cursor ...

func (*Cursor) All

func (c *Cursor) All(result interface{}) error

func (*Cursor) Close

func (c *Cursor) Close() error

func (*Cursor) Next

func (c *Cursor) Next() bool

Next gets the next result from this cursor. Returns true if there were no errors and the next result is available for decoding.

type DB

type DB struct {
	*mongo.Database
	// contains filtered or unexported fields
}

DB ...

func (*DB) Collection

func (db *DB) Collection(s string, options ...*options.CollectionOptions) *Collection

Collection ...

type TransactionCallback

type TransactionCallback func(*mongo.Collection, mongo.SessionContext) error

TransactionCallback ...

Jump to

Keyboard shortcuts

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