mongodb

package
v0.0.0-...-21d4feb Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertSortParameters

func ConvertSortParameters(params api.SortParameters) []string

ConvertSortParameters to mongodb query string

func NewCRUDTable

func NewCRUDTable(session *mgo.Session, db, table string) api.EntityCRUD

NewCRUDTable sets up a new Default struct

Types

type Default

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

Default contains the basic implementation of the MongoCRUD interface

func (*Default) Delete

func (d *Default) Delete(id interface{}) error

Delete deletes a resource with specified ID

func (*Default) DeleteAll

func (d *Default) DeleteAll(pred interface{}) error

DeleteAll deletes resources that match the passed filter

func (*Default) Find

func (d *Default) Find(id interface{}, value interface{}) error

Find searches for a resource in the database and then returns a cursor

func (*Default) FindBy

func (d *Default) FindBy(key string, value interface{}, results interface{}) error

FindBy is an utility for fetching values if they are stored in a key-value manenr.

func (*Default) FindByAndCount

func (d *Default) FindByAndCount(key string, value interface{}) (int, error)

FindByAndCount returns the number of elements that match the filter

func (*Default) FindByAndFetch

func (d *Default) FindByAndFetch(key string, value interface{}, results interface{}) error

FindByAndFetch retrieves a value by key and then fills results with the result.

func (*Default) FindFetchOne

func (d *Default) FindFetchOne(id string, value interface{}) error

FindFetchOne searches for a resource and then unmarshals the first row into value

func (*Default) FindOneBy

func (d *Default) FindOneBy(key string, value interface{}, result interface{}) error

FindOneBy is an utility for fetching values if they are stored in a key-value manenr.

func (*Default) GetDBName

func (d *Default) GetDBName() string

GetDBName returns database's name

func (*Default) GetSession

func (d *Default) GetSession() interface{}

GetSession returns the current session

func (*Default) GetTable

func (d *Default) GetTable() interface{}

GetTable returns the table as a mgo.Collection

func (*Default) GetTableName

func (d *Default) GetTableName() string

GetTableName returns table's name

func (*Default) Insert

func (d *Default) Insert(data interface{}) error

Insert inserts a document into the database

func (*Default) InsertOrUpdate

func (d *Default) InsertOrUpdate(id interface{}, data interface{}) (interface{}, error)

InsertOrUpdate inserts or update document if exists

func (*Default) List

func (d *Default) List(results interface{}, sortParams *api.SortParameters, pagination *api.Pagination) error

List all entities from the database

func (*Default) Search

func (d *Default) Search(results interface{}, filter interface{}, sortParams *api.SortParameters, pagination *api.Pagination) error

Search all entities from the database

func (*Default) Update

func (d *Default) Update(selector interface{}, data interface{}) error

Update performs an update on an existing resource according to passed data

func (*Default) UpdateID

func (d *Default) UpdateID(id interface{}, data interface{}) error

UpdateID performs an update on an existing resource with ID that equals the id argument

func (*Default) Where

func (d *Default) Where(filter interface{}, results interface{}) error

Where allows filtering with multiple fields

func (*Default) WhereAndFetch

func (d *Default) WhereAndFetch(filter interface{}, results interface{}) error

WhereAndFetch filters with multiple fields and then fills results with all found resources

func (*Default) WhereAndFetchLimit

func (d *Default) WhereAndFetchLimit(filter interface{}, paginator *api.Pagination, results interface{}) error

WhereAndFetchLimit filters with multiple fields and then fills results with all found resources

func (*Default) WhereAndFetchOne

func (d *Default) WhereAndFetchOne(filter interface{}, result interface{}) error

WhereAndFetchOne filters with multiple fields and then fills result with the first found resource

func (*Default) WhereCount

func (d *Default) WhereCount(filter interface{}) (int, error)

WhereCount allows counting with multiple fields

Jump to

Keyboard shortcuts

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