Documentation
¶
Index ¶
- type BulkCollection
- type BulkDocument
- type Client
- type Collection
- func (c *Collection) Add(data interface{}) (*Document, error)
- func (c *Collection) All() *CollectionQuery
- func (c *Collection) Bulk(run func(collection *BulkCollection) error, ordered bool) error
- func (c *Collection) CreateIndex(fields map[string]Index) error
- func (c *Collection) Delete() error
- func (c *Collection) DeleteDocumentsWhere(filter filter.Filter) error
- func (c *Collection) Document(id string) *Document
- func (c *Collection) Transaction(run func(c *Collection) error) error
- func (c *Collection) UpdateDocumentsWhere(filter filter.Filter, upsert bool, updates ...update.Update) error
- func (c *Collection) Where(filter filter.Filter) *CollectionQuery
- type CollectionQuery
- func (cq *CollectionQuery) AddFields(spec map[string]interface{}) *CollectionQuery
- func (cq *CollectionQuery) Count(field string) *CollectionQuery
- func (cq *CollectionQuery) DocumentIterator() (*Iterator, error)
- func (cq *CollectionQuery) Join(localField string, foreignCollection string, foreignField string, as string) *CollectionQuery
- func (cq *CollectionQuery) Limit(n int) *CollectionQuery
- func (cq *CollectionQuery) Modify(spec map[string]interface{}) *CollectionQuery
- func (cq *CollectionQuery) Sample(n int) *CollectionQuery
- func (cq *CollectionQuery) Skip(n int) *CollectionQuery
- func (cq *CollectionQuery) Sort(sorters ...*Sorter) *CollectionQuery
- func (cq *CollectionQuery) Transaction(run func(cq *CollectionQuery) error) error
- type Database
- type Document
- type DocumentData
- type Index
- type Iterator
- type Sorter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkCollection ¶ added in v0.3.0
type BulkCollection struct { ID string Collection *Collection // contains filtered or unexported fields }
BulkCollection is a collection which is used for bulk writing
func (*BulkCollection) Add ¶ added in v0.3.0
func (c *BulkCollection) Add(data interface{})
Add a document with a certain value
func (*BulkCollection) DeleteDocumentsWhere ¶ added in v0.3.0
func (c *BulkCollection) DeleteDocumentsWhere(filter filter.Filter)
DeleteDocumentsWhere the filter matches
func (*BulkCollection) Document ¶ added in v0.3.0
func (c *BulkCollection) Document(id string) *BulkDocument
Document get a single document from a collection
func (*BulkCollection) UpdateDocumentsWhere ¶ added in v0.3.0
func (c *BulkCollection) UpdateDocumentsWhere(filter filter.Filter, upsert bool, updates ...update.Update) error
UpdateDocumentsWhere the filter matches
type BulkDocument ¶ added in v0.3.0
type BulkDocument struct { ID string Collection *BulkCollection }
BulkDocument is a document which is used for bulk writing
func (*BulkDocument) Delete ¶ added in v0.3.0
func (d *BulkDocument) Delete() error
Delete a document from a collection
func (*BulkDocument) Set ¶ added in v0.3.0
func (d *BulkDocument) Set(data interface{}) error
Set a document to a certain value
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the mongo client
type Collection ¶
Collection is a collection on the database
func (*Collection) Add ¶
func (c *Collection) Add(data interface{}) (*Document, error)
Add a document with a certain value
func (*Collection) All ¶ added in v0.2.0
func (c *Collection) All() *CollectionQuery
All returns an abstract of the collection of all documents
func (*Collection) Bulk ¶ added in v0.3.0
func (c *Collection) Bulk(run func(collection *BulkCollection) error, ordered bool) error
Bulk is used to do bulk writes
func (*Collection) CreateIndex ¶
func (c *Collection) CreateIndex(fields map[string]Index) error
CreateIndex for a single or group of fields
func (*Collection) DeleteDocumentsWhere ¶ added in v0.3.0
func (c *Collection) DeleteDocumentsWhere(filter filter.Filter) error
DeleteDocumentsWhere the filter matches
func (*Collection) Document ¶
func (c *Collection) Document(id string) *Document
Document get a single document from a collection
func (*Collection) Transaction ¶ added in v0.3.0
func (c *Collection) Transaction(run func(c *Collection) error) error
Transaction means all operations executed in the run function are atomic
func (*Collection) UpdateDocumentsWhere ¶ added in v0.3.0
func (c *Collection) UpdateDocumentsWhere(filter filter.Filter, upsert bool, updates ...update.Update) error
UpdateDocumentsWhere the filter matches
func (*Collection) Where ¶
func (c *Collection) Where(filter filter.Filter) *CollectionQuery
Where returns an abstract of the collection of documents that match the filter
type CollectionQuery ¶
type CollectionQuery struct { Collection *Collection // contains filtered or unexported fields }
CollectionQuery is a filtered abstraction of a group of documents
func (*CollectionQuery) AddFields ¶ added in v0.2.0
func (cq *CollectionQuery) AddFields(spec map[string]interface{}) *CollectionQuery
AddFields adds some fields to the returned documents
func (*CollectionQuery) Count ¶ added in v0.2.0
func (cq *CollectionQuery) Count(field string) *CollectionQuery
Count returns the amount of documents in a single document under the field 'field'
func (*CollectionQuery) DocumentIterator ¶
func (cq *CollectionQuery) DocumentIterator() (*Iterator, error)
DocumentIterator gives you an iterator to loop over the documents
func (*CollectionQuery) Join ¶ added in v0.2.0
func (cq *CollectionQuery) Join(localField string, foreignCollection string, foreignField string, as string) *CollectionQuery
Join gets all documents from a foreign collection in this database, filters them by checking if the value of foreignField matches the value of localField and if so adding these to the original document as an array under the 'as' key
func (*CollectionQuery) Limit ¶ added in v0.2.0
func (cq *CollectionQuery) Limit(n int) *CollectionQuery
Limit to only return n documents
func (*CollectionQuery) Modify ¶ added in v0.2.0
func (cq *CollectionQuery) Modify(spec map[string]interface{}) *CollectionQuery
Modify changes the data structure of the field like specified by the specification
func (*CollectionQuery) Sample ¶ added in v0.2.0
func (cq *CollectionQuery) Sample(n int) *CollectionQuery
Sample returns n amount of documents randomly picked from the document pool
func (*CollectionQuery) Skip ¶ added in v0.2.0
func (cq *CollectionQuery) Skip(n int) *CollectionQuery
Skip skips the first n documents
func (*CollectionQuery) Sort ¶ added in v0.4.0
func (cq *CollectionQuery) Sort(sorters ...*Sorter) *CollectionQuery
Sort sorts a collection by a certain order
func (*CollectionQuery) Transaction ¶ added in v0.3.0
func (cq *CollectionQuery) Transaction(run func(cq *CollectionQuery) error) error
Transaction means all operations executed in the run function are atomic
type Database ¶
Database is a database instance
func (*Database) Collection ¶
func (d *Database) Collection(id string) *Collection
Collection in the database by id
type Document ¶
type Document struct { ID string Collection *Collection }
Document is a document in a collection
func (*Document) Get ¶
func (d *Document) Get() (*DocumentData, error)
Get the contents of a document
func (*Document) Transaction ¶ added in v0.3.0
Transaction means all operations executed in the run function are atomic
type DocumentData ¶
type DocumentData struct { Document *Document // contains filtered or unexported fields }
DocumentData is the data in a document
func (*DocumentData) Data ¶
func (d *DocumentData) Data() (interface{}, error)
Data decodes some data and returns an interface
func (*DocumentData) DataTo ¶
func (d *DocumentData) DataTo(data interface{}) error
DataTo decodes some data into an interface
type Iterator ¶
type Iterator struct { Collection *Collection // contains filtered or unexported fields }
Iterator to iterate over documents