mongodb

package
v0.0.0-...-677ce44 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

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

Mongo indicates the database adapter between the app and Mongodb.

func New

func New(col *mongo.Collection) *Mongo

New initializes Mongo Structure.

func (*Mongo) Count

func (me *Mongo) Count(ctx context.Context, query interface{}) (int64, error)

Count counts the document.

func (*Mongo) Delete

func (me *Mongo) Delete(
	ctx context.Context, filter interface{},
) (count int64, err error)

Delete deletes the matched document by query.

func (*Mongo) DeleteMany

func (me *Mongo) DeleteMany(
	ctx context.Context, filter interface{},
) (count int64, err error)

DeleteMany deletes the matched document**s** by query.

func (*Mongo) Find

func (me *Mongo) Find(
	ctx context.Context,
	query interface{},
	docs interface{},
	opts ...interface{},
) (err error)

Find finds documents by the specified query.

func (*Mongo) FindOne

func (me *Mongo) FindOne(
	ctx context.Context,
	query interface{},
	resdoc interface{},
	opts ...interface{},
) (err error)

FindOne finds a document by the specified query

func (*Mongo) Insert

func (me *Mongo) Insert(
	ctx context.Context, doc interface{},
) (insID interface{}, err error)

Insert a single document.

func (*Mongo) InsertMany

func (me *Mongo) InsertMany(
	ctx context.Context, docs []interface{},
) (insertedIDs []interface{}, err error)

InsertMany store multiple documents into MongoDB.

func (*Mongo) Update

func (me *Mongo) Update(
	ctx context.Context,
	query interface{},
	update interface{},
) (res *adapter.UpdateSummary, err error)

Update the single matched doc by query, with the diff. "update".

func (*Mongo) UpdateMany

func (me *Mongo) UpdateMany(
	ctx context.Context,
	query interface{},
	update interface{},
) (res *adapter.UpdateSummary, err error)

UpdateMany the all matched docs by query, with the diff. "update".

Jump to

Keyboard shortcuts

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