Documentation ¶
Index ¶
- Constants
- type Document
- type DocumentList
- type Gongo
- type Model
- func (c *Model) Collection() *mongo.Collection
- func (c *Model) Create(document interface{}, timeout ...*int) (*Document, error)
- func (c *Model) Database() *mongo.Database
- func (c *Model) Find(filter interface{}, opts ...*options.FindOptions) (DocumentList, error)
- func (c *Model) FindByID(id interface{}, opts ...*options.FindOneOptions) (*Document, error)
- func (c *Model) FindByIDWithTimeout(id interface{}, timeout *int, opts ...*options.FindOneOptions) (*Document, error)
- func (c *Model) FindOne(filter interface{}, opts ...*options.FindOneOptions) (*Document, error)
- func (c *Model) FindOneAndDelete(filter interface{}, opts ...*options.FindOneAndDeleteOptions) (*Document, error)
- func (c *Model) FindOneAndDeleteWithTimeout(filter interface{}, timeout *int, opts ...*options.FindOneAndDeleteOptions) (*Document, error)
- func (c *Model) FindOneAndUpdate(filter interface{}, update interface{}, ...) (*Document, error)
- func (c *Model) FindOneAndUpdateWithTimeout(filter interface{}, update interface{}, timeout *int, ...) (*Document, error)
- func (c *Model) FindOneWithTimeout(filter interface{}, timeout *int, opts ...*options.FindOneOptions) (*Document, error)
- func (c *Model) FindWithTimeout(filter interface{}, timeout *int, opts ...*options.FindOptions) (DocumentList, error)
- func (c *Model) Hydrate(filter interface{}, timeout ...*int) (*Document, error)
- func (c *Model) InsertOne(doc interface{}, opts ...*options.InsertOneOptions) (*Document, error)
- func (c *Model) InsertOneWithTimeout(doc interface{}, timeout *int, opts ...*options.InsertOneOptions) (*Document, error)
- func (c *Model) New(document interface{}) (*Document, error)
- type ModelOptions
- type Options
- type PostMiddleware
- type PostMiddlewareFunc
- type PreMiddleware
- type PreMiddlewareFunc
- type Schema
- type SchemaField
- type SchemaFieldMap
- type SchemaOptions
- type ValidatorFunc
- type VirtualConfig
- type VirtualFieldMap
- type VirtualGetFunc
- type VirtualSetFunc
Constants ¶
const ( StringType = "String" IntType = "Int" FloatType = "Float" BoolType = "Bool" MixedType = "Mixed" ObjectIDType = "ObjectID" )
Built-in types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document a mongodb document wrapper
type DocumentList ¶
type DocumentList []*Document
DocumentList a list of documents
func (*DocumentList) Decode ¶
func (c *DocumentList) Decode(target interface{}) error
Decode decodes all of the documents in a document list to a target
type Gongo ¶
type Gongo struct {
// contains filtered or unexported fields
}
Gongo main interface
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model model
func (*Model) Collection ¶
func (c *Model) Collection() *mongo.Collection
Collection returns the collection object
func (*Model) Find ¶
func (c *Model) Find(filter interface{}, opts ...*options.FindOptions) (DocumentList, error)
Find finds documents
func (*Model) FindByID ¶
func (c *Model) FindByID(id interface{}, opts ...*options.FindOneOptions) (*Document, error)
FindByID finds one document by id
func (*Model) FindByIDWithTimeout ¶
func (c *Model) FindByIDWithTimeout(id interface{}, timeout *int, opts ...*options.FindOneOptions) (*Document, error)
FindByIDWithTimeout finds one document by id
func (*Model) FindOne ¶
func (c *Model) FindOne(filter interface{}, opts ...*options.FindOneOptions) (*Document, error)
FindOne finds one document
func (*Model) FindOneAndDelete ¶
func (c *Model) FindOneAndDelete( filter interface{}, opts ...*options.FindOneAndDeleteOptions, ) (*Document, error)
FindOneAndDelete finds a document and deletes it
func (*Model) FindOneAndDeleteWithTimeout ¶
func (c *Model) FindOneAndDeleteWithTimeout( filter interface{}, timeout *int, opts ...*options.FindOneAndDeleteOptions, ) (*Document, error)
FindOneAndDeleteWithTimeout finds a document and deletes it
func (*Model) FindOneAndUpdate ¶
func (c *Model) FindOneAndUpdate( filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions, ) (*Document, error)
FindOneAndUpdate finds a document and updates it
func (*Model) FindOneAndUpdateWithTimeout ¶
func (c *Model) FindOneAndUpdateWithTimeout( filter interface{}, update interface{}, timeout *int, opts ...*options.FindOneAndUpdateOptions, ) (*Document, error)
FindOneAndUpdateWithTimeout finds a document and updates it
func (*Model) FindOneWithTimeout ¶
func (c *Model) FindOneWithTimeout(filter interface{}, timeout *int, opts ...*options.FindOneOptions) (*Document, error)
FindOneWithTimeout finds one document
func (*Model) FindWithTimeout ¶
func (c *Model) FindWithTimeout(filter interface{}, timeout *int, opts ...*options.FindOptions) (DocumentList, error)
FindWithTimeout finds documents
func (*Model) InsertOne ¶
func (c *Model) InsertOne(doc interface{}, opts ...*options.InsertOneOptions) (*Document, error)
InsertOne inserts one document
func (*Model) InsertOneWithTimeout ¶
func (c *Model) InsertOneWithTimeout(doc interface{}, timeout *int, opts ...*options.InsertOneOptions) (*Document, error)
InsertOneWithTimeout inserts one document
type ModelOptions ¶
ModelOptions options for the model
type PostMiddleware ¶
type PostMiddleware struct { Operation string Handler PostMiddlewareFunc Async bool }
PostMiddleware a middleware
type PostMiddlewareFunc ¶
PostMiddlewareFunc middleware for post
type PreMiddleware ¶
type PreMiddleware struct { Operation string Handler PreMiddlewareFunc Async bool }
PreMiddleware a middleware
type PreMiddlewareFunc ¶
PreMiddlewareFunc middleware for document
type Schema ¶
type Schema struct { Fields SchemaFieldMap Options *SchemaOptions Virtuals *VirtualFieldMap // contains filtered or unexported fields }
Schema a schema definition
func (*Schema) Post ¶
func (c *Schema) Post(operation string, handler PostMiddlewareFunc, async ...*bool) *Schema
Post adds post middleware
func (*Schema) Pre ¶
func (c *Schema) Pre(operation string, handler PreMiddlewareFunc, async ...*bool) *Schema
Pre adds pre middleware
func (*Schema) Virtual ¶
func (c *Schema) Virtual(config *VirtualConfig) *Schema
Virtual adds a virtual field config
type SchemaField ¶
type SchemaField struct { Type interface{} Required bool Unique bool Default interface{} Validate *[]ValidatorFunc Meta *map[string]interface{} // contains filtered or unexported fields }
SchemaField a schema field definition
type ValidatorFunc ¶
type ValidatorFunc func(value interface{}) error
ValidatorFunc a function that performs a validation
type VirtualConfig ¶
type VirtualConfig struct { Name string Get VirtualGetFunc Set VirtualSetFunc }
VirtualConfig defines the virtual config
type VirtualFieldMap ¶
type VirtualFieldMap map[string]*VirtualConfig
VirtualFieldMap a map of virtual types
type VirtualGetFunc ¶
VirtualGetFunc for resolving virtual
type VirtualSetFunc ¶
VirtualSetFunc for resolving virtual