Documentation
¶
Index ¶
- Variables
- type Collection
- func (c *Collection) CountDocuments(filter interface{}) (int, error)
- func (c *Collection) Database() *Database
- func (c *Collection) DeleteMany(filter []interface{}) (*DeleteResult, error)
- func (c *Collection) DeleteOne(filter interface{}) (*DeleteResult, error)
- func (c *Collection) Drop() error
- func (c *Collection) Find(filter interface{}) (MultiResult, interface{}, error)
- func (c *Collection) FindOne(filter interface{}, result interface{}) (*SingleResult, error)
- func (c *Collection) GetByID(id interface{}) (interface{}, error)
- func (c *Collection) InsertMany(docs []interface{}) ([]InsertID, error)
- func (c *Collection) InsertOne(doc interface{}) (InsertID, error)
- func (c *Collection) Name() string
- func (c *Collection) UpdateMany(docs []interface{}) (*UpdateResult, error)
- func (c *Collection) UpdateOne(doc interface{}) (*UpdateResult, error)
- type Database
- type DeleteResult
- type InsertID
- type MultiResult
- type SingleResult
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection represents a collection of MingoDB documents.
func (*Collection) CountDocuments ¶
func (c *Collection) CountDocuments(filter interface{}) (int, error)
CountDocuments returns the number of documents that match the filter.
func (*Collection) Database ¶
func (c *Collection) Database() *Database
Database returns a pointer to the collection's parent database.
func (*Collection) DeleteMany ¶
func (c *Collection) DeleteMany(filter []interface{}) (*DeleteResult, error)
DeleteMany inserts multiple documents into the collection.
func (*Collection) DeleteOne ¶
func (c *Collection) DeleteOne(filter interface{}) (*DeleteResult, error)
DeleteOne deletes a single document into the collection based on the filter
func (*Collection) Find ¶
func (c *Collection) Find(filter interface{}) (MultiResult, interface{}, error)
Find returns (up to) multiple documents from the collection based on the filter provided.
func (*Collection) FindOne ¶
func (c *Collection) FindOne(filter interface{}, result interface{}) (*SingleResult, error)
FindOne returns the first document (if any) that matches the filter.
func (*Collection) GetByID ¶
func (c *Collection) GetByID(id interface{}) (interface{}, error)
func (*Collection) InsertMany ¶
func (c *Collection) InsertMany(docs []interface{}) ([]InsertID, error)
InsertMany inserts multiple documents into the collection. Returns an array of the inserted documents' _id values (If generated by the DB, will be of type primitive.ObjectID).
func (*Collection) InsertOne ¶
func (c *Collection) InsertOne(doc interface{}) (InsertID, error)
InsertOne inserts a single document into the collection. Returns the _id of the inserted document (if generated by the DB, will be of type primitive.ObjectID).
Expects doc to be either a struct or a map[string]interface{}. Note that if doc is a struct, only expored fields will be stored.
func (*Collection) Name ¶
func (c *Collection) Name() string
Name returns the name of the collection.
func (*Collection) UpdateMany ¶
func (c *Collection) UpdateMany(docs []interface{}) (*UpdateResult, error)
UpdateMany
func (*Collection) UpdateOne ¶
func (c *Collection) UpdateOne(doc interface{}) (*UpdateResult, error)
UpdateOne
type Database ¶
type Database struct { Path string // contains filtered or unexported fields }
Database represents a MingoDB database connection.
func Open ¶
Open creates a new database connection at the path specified. If the path does not exist, it will be created.
func (*Database) Close ¶
Close closes the database connection and cleans up any resources. Will block until all pending operations have completed.
func (*Database) Collection ¶
func (db *Database) Collection(name string) (*Collection, error)
Collection returns a DB collection object with the specified name. If the collection does not exist, it will be created.
func (*Database) CollectionMust ¶
func (db *Database) CollectionMust(name string) *Collection
CollectionMust returns a DB collection object with the specified name. If the collection does not exist, it will be created. Note: This function wraps Collection() and panics if an error is returned.
type DeleteResult ¶
type DeleteResult struct {
DeleteCount int // Number of rows deleted
}
type MultiResult ¶
type MultiResult struct { //data []byte ResultCount int // Number of returned results }
type SingleResult ¶
type SingleResult struct {
// contains filtered or unexported fields
}
type UpdateResult ¶
type UpdateResult struct {
UpdateCount int // Number of rows updated
}