Documentation ¶
Overview ¶
The accessory package provides a high level API for go object storage in databases (MongoDB).
Documents ¶
Documents are mapped to collections through their type. The type must be a struct, and the struct must have a field which is a primitive.ObjectID or a string. Use struct tags to define which field is the key field. For example,
type Source struct { Id string `bson:"_id,omitempty"` Url string `bson:"url,unique"` }
The bson tags should either contain metadata or '-' to skip the field in the MongoDB database. Use the following flags:
- unique - The field is unique in the collection, and an index is generated for the field (This is not part of the underlying MongoDB driver)
- index - An index is generated for the field (This is not part of the underlying MongoDB driver)
- omitempty - The field is omitted from the document if it is empty
Index ¶
- func NewCollection(database *driver.Database, meta *meta, fn trace.Func) *collection
- func NewCursor(c *driver.Cursor, t reflect.Type) *cursor
- func NewDatabase(conn *conn, name string, meta metaLookupFunc, trace trace.Func) *database
- func NewFilter() *filter
- func NewMeta(t reflect.Type, name string) *meta
- func NewSort() *sort
- func Open(ctx context.Context, url *url.URL, opts ...ClientOpt) (Conn, error)
- type ClientOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCollection ¶
func NewDatabase ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.