Documentation ¶
Index ¶
- Variables
- type BulkWriteResult
- type Collection
- func (c *Collection) Aggregate(pipeline interface{}, results interface{}, opts ...*options.AggregateOptions) error
- func (c *Collection) Count(filter bson.D, opts ...*options.CountOptions) int64
- func (c *Collection) FindByID(id primitive.ObjectID, result interface{}) error
- func (c *Collection) Index(keys ...bson.M) ([]string, error)
- func (c *Collection) Insert(doc interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (c *Collection) InsertAll(docs []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
- func (c *Collection) Remove(filter bson.D, opts ...*options.DeleteOptions) error
- func (c *Collection) RemoveAll(filter bson.D, opts ...*options.DeleteOptions) error
- func (c *Collection) RemoveID(id primitive.ObjectID, opts ...*options.DeleteOptions) error
- func (c *Collection) Update(filter bson.D, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (c *Collection) UpdateAll(filter bson.D, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (c *Collection) UpdateByID(id primitive.ObjectID, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (c *Collection) Where(filter bson.D) *Session
- type CollectionSpecification
- type Database
- type DatabaseSpecification
- type DeleteResult
- type IndexSpecification
- type InsertManyResult
- type InsertOneResult
- type ListDatabasesResult
- type Pipeline
- type RewrapManyDataKeyResult
- type Session
- func (s *Session) C(collection string) *Collection
- func (s *Session) Client() *mongo.Client
- func (s *Session) Collection(collection string) *Collection
- func (s *Session) Connect() error
- func (s *Session) DB(db string) *Database
- func (s *Session) FetchAll(results interface{}) error
- func (s *Session) Find(result interface{}) error
- func (s *Session) Pagination(page, limit int, results interface{}) (int64, error)
- func (s *Session) Ping() error
- func (s *Session) Run(size int32, callback func(*mongo.Cursor)) error
- func (s *Session) SetOpts(opts ...*options.FindOptions) *Session
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
var ErrMongoNoDoc = errors.New("mongo: no document results")
ErrMongoNoDoc is mongo: no document results
Functions ¶
This section is empty.
Types ¶
type BulkWriteResult ¶
type BulkWriteResult = mongo.BulkWriteResult
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection mongo-driver collection
func (*Collection) Aggregate ¶
func (c *Collection) Aggregate(pipeline interface{}, results interface{}, opts ...*options.AggregateOptions) error
Aggregate performs an aggregation pipeline.
func (*Collection) Count ¶
func (c *Collection) Count(filter bson.D, opts ...*options.CountOptions) int64
Count gets the number of documents matching the filter.
func (*Collection) FindByID ¶
func (c *Collection) FindByID(id primitive.ObjectID, result interface{}) error
FindByID finds a single document by id.
func (*Collection) Index ¶
func (c *Collection) Index(keys ...bson.M) ([]string, error)
Index creates an index with the given keys and options.
func (*Collection) Insert ¶
func (c *Collection) Insert(doc interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
InsertWithResult inserts a single document into the collection and returns insert one result.
func (*Collection) InsertAll ¶
func (c *Collection) InsertAll(docs []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
InsertAllWithResult inserts the provided documents and returns insert many result.
func (*Collection) Remove ¶
func (c *Collection) Remove(filter bson.D, opts ...*options.DeleteOptions) error
Remove deletes a single document from the collection.
func (*Collection) RemoveAll ¶
func (c *Collection) RemoveAll(filter bson.D, opts ...*options.DeleteOptions) error
RemoveAll deletes multiple documents from the collection.
func (*Collection) RemoveID ¶
func (c *Collection) RemoveID(id primitive.ObjectID, opts ...*options.DeleteOptions) error
RemoveID deletes a single document from the collection by id.
func (*Collection) Update ¶
func (c *Collection) Update(filter bson.D, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateWithResult updates a single document in the collection and returns update result.
func (*Collection) UpdateAll ¶
func (c *Collection) UpdateAll(filter bson.D, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateAll updates multiple documents in the collection.
func (*Collection) UpdateByID ¶
func (c *Collection) UpdateByID(id primitive.ObjectID, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateByID updates a single document in the collection by id
type CollectionSpecification ¶
type CollectionSpecification = mongo.CollectionSpecification
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database mongo-driver database
func (*Database) Collection ¶
func (d *Database) Collection(collection string) *Collection
Collection returns collection.
func (*Database) CollectionNames ¶
CollectionNames returns the collection names present in database.
type DatabaseSpecification ¶
type DatabaseSpecification = mongo.DatabaseSpecification
type DeleteResult ¶
type DeleteResult = mongo.DeleteResult
type IndexSpecification ¶
type IndexSpecification = mongo.IndexSpecification
type InsertManyResult ¶
type InsertManyResult = mongo.InsertManyResult
type InsertOneResult ¶
type InsertOneResult = mongo.InsertOneResult
type ListDatabasesResult ¶
type ListDatabasesResult = mongo.ListDatabasesResult
type RewrapManyDataKeyResult ¶
type RewrapManyDataKeyResult = mongo.RewrapManyDataKeyResult
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session mongo session
func New ¶
New session
Relevant documentation:
https://docs.mongodb.com/manual/reference/connection-string/
func (*Session) Collection ¶
func (s *Session) Collection(collection string) *Collection
Collection returns collection
func (*Session) Pagination ¶
Pagination pagination
func (*Session) Ping ¶
Ping verifies that the client can connect to the topology. If readPreference is nil then will use the client's default read preference.
type UpdateResult ¶
type UpdateResult = mongo.UpdateResult