mongodb

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpressionToBSON added in v0.2.0

func ExpressionToBSON(criteria expression.Expression) bson.M

ExpressionToBSON converts a data.Expression value into pure bson.

Types

type Collection added in v0.3.8

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

Collection wraps a mongodb.Collection with all of the methods required by the data.Collection interface

func (Collection) Delete added in v0.3.8

func (c Collection) Delete(object data.Object, note string) *derp.Error

Delete removes a single object from the database, using a "virtual delete"

func (Collection) List added in v0.3.8

func (c Collection) List(criteria expression.Expression, options ...option.Option) (data.Iterator, *derp.Error)

List retrieves a group of objects from the database

func (Collection) Load added in v0.3.8

func (c Collection) Load(criteria expression.Expression, target data.Object) *derp.Error

Load retrieves a single object from the database

func (Collection) Save added in v0.3.8

func (c Collection) Save(object data.Object, note string) *derp.Error

Save inserts/updates a single object in the database.

type Iterator added in v0.2.5

type Iterator struct {
	Context context.Context
	Cursor  *mongo.Cursor
}

Iterator wraps the mongodb Cursor object

func NewIterator added in v0.2.5

func NewIterator(context context.Context, cursor *mongo.Cursor) Iterator

NewIterator returns a fully populated Iterator object

func (Iterator) Close added in v0.2.5

func (iterator Iterator) Close() *derp.Error

Close closes the wrapped Cursor

func (Iterator) Count added in v0.9.0

func (iterator Iterator) Count() int

Count returns the total number of records contained by this iterator

func (Iterator) Next added in v0.2.5

func (iterator Iterator) Next(output data.Object) bool

Next populates the next value from the wrapped Cursor, or returns FALSE

type Server added in v0.3.6

type Server struct {
	Client   *mongo.Client
	Database *mongo.Database
}

Server is an abstract representation of a MongoDB database. It implements the data.Server interface, so that it should be usable anywhere that requires a data.Server.

func New

func New(uri string, database string) (Server, *derp.Error)

New returns a fully populated mongodb.Server. It requires that you provide the URI for the mongodb cluster, along with the name of the database to be used for all transactions.

func (Server) Session added in v0.3.6

func (server Server) Session(ctx context.Context) (data.Session, error)

Session returns a new client session that can be used to perform CRUD transactions on this datastore.

type Session

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

Session represents a single database session, such as a session encompassing all of the database queries to respond to a single REST service call.

func (Session) Close

func (s Session) Close()

Close cleans up any remaining connections that need to be removed.

func (Session) Collection added in v0.3.8

func (s Session) Collection(collection string) data.Collection

Collection returns a reference to an individual database collection.

Jump to

Keyboard shortcuts

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