mongo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncProvider

type FuncProvider struct {
	Session    *mgo.Session
	Collection string
}

FuncProvider implements dbProvider for MongoDB.

Methods are safe for concurrent use, however the struct fields are not.

func NewProvider

func NewProvider(endpoint *url.URL, tableName string) (*FuncProvider, error)

NewProvider returns an instance of FuncProvider.

The following options are available in addition to the usual dial string options provided by the gmo driver:

readConcern: majority/local/linearizable
writeConcern: majority/<number>
journal: true/false
fsync: true/false

func (*FuncProvider) GetMaxID

func (p *FuncProvider) GetMaxID() (uint64, error)

GetMaxID returns the largest ID in the collection.

func (*FuncProvider) InsertRecord

func (p *FuncProvider) InsertRecord(data *record.Person, id idgen.Generator, rnd *rand.Rand) bool

InsertRecord generates a new random record and inserts it with an ID provided by id.GetNew

func (*FuncProvider) ReadMostRecentRecord

func (p *FuncProvider) ReadMostRecentRecord(_ *record.Person, _ idgen.Generator, _ *rand.Rand) bool

ReadMostRecentRecord fetches the most recently inserted record by performing a sort on the ID field, and limiting the results to a single record.

func (*FuncProvider) ReadRange

func (p *FuncProvider) ReadRange(_ *record.Person, _ idgen.Generator, _ *rand.Rand) bool

ReadRange performs a range query on the age field.

THe query attempts to fetch all records where age is greater than 45 and less than 75.

func (*FuncProvider) ReadRecord

func (p *FuncProvider) ReadRecord(_ *record.Person, id idgen.Generator, rnd *rand.Rand) bool

ReadRecord attempts to fetch the record with an ID returned by id.GetExisting.

func (*FuncProvider) UpdateRecord

func (p *FuncProvider) UpdateRecord(_ *record.Person, id idgen.Generator, rnd *rand.Rand) bool

UpdateRecord attempts to update the record with ID returned by id.GetExisting.

The balance field is changed to a random value from rnd.

Jump to

Keyboard shortcuts

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