Documentation ¶
Index ¶
- type Collection
- func (c *Collection) Count(selector interface{}) (int64, error)
- func (c *Collection) Find(filter interface{}) *Session
- func (c *Collection) Insert(document interface{}) error
- func (c *Collection) InsertAll(documents []interface{}) error
- func (c *Collection) InsertAllWithResult(documents []interface{}) (result *mongo.InsertManyResult, err error)
- func (c *Collection) InsertWithResult(document interface{}) (result *mongo.InsertOneResult, err error)
- func (c *Collection) Remove(selector interface{}) error
- func (c *Collection) RemoveAll(selector interface{}) error
- func (c *Collection) RemoveID(id interface{}) error
- func (c *Collection) Update(selector interface{}, update interface{}, upsert ...bool) error
- func (c *Collection) UpdateAll(selector interface{}, update interface{}, upsert ...bool) (*mongo.UpdateResult, error)
- func (c *Collection) UpdateID(id interface{}, update interface{}) error
- func (c *Collection) UpdateWithResult(selector interface{}, update interface{}, upsert ...bool) (result *mongo.UpdateResult, err error)
- type Database
- type Session
- func (s *Session) All(result interface{}) error
- 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) Limit(limit int64) *Session
- func (s *Session) One(result interface{}) error
- func (s *Session) Ping() error
- func (s *Session) SetPoolLimit(limit uint64)
- func (s *Session) Skip(skip int64) *Session
- func (s *Session) Sort(sort interface{}) *Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection mongo-driver collection
func (*Collection) Count ¶
func (c *Collection) Count(selector interface{}) (int64, error)
Count gets the number of documents matching the filter.
func (*Collection) Find ¶
func (c *Collection) Find(filter interface{}) *Session
Find finds docs by given filter
func (*Collection) Insert ¶
func (c *Collection) Insert(document interface{}) error
Insert inserts a single document into the collection.
func (*Collection) InsertAll ¶
func (c *Collection) InsertAll(documents []interface{}) error
InsertAll inserts the provided documents.
func (*Collection) InsertAllWithResult ¶
func (c *Collection) InsertAllWithResult(documents []interface{}) (result *mongo.InsertManyResult, err error)
InsertAllWithResult inserts the provided documents and returns insert many result.
func (*Collection) InsertWithResult ¶
func (c *Collection) InsertWithResult(document interface{}) (result *mongo.InsertOneResult, err error)
InsertWithResult inserts a single document into the collection and returns insert one result.
func (*Collection) Remove ¶
func (c *Collection) Remove(selector interface{}) error
Remove deletes a single document from the collection.
func (*Collection) RemoveAll ¶
func (c *Collection) RemoveAll(selector interface{}) error
RemoveAll deletes multiple documents from the collection.
func (*Collection) RemoveID ¶
func (c *Collection) RemoveID(id interface{}) error
RemoveID deletes a single document from the collection by id.
func (*Collection) Update ¶
func (c *Collection) Update(selector interface{}, update interface{}, upsert ...bool) error
Update updates a single document in the collection.
func (*Collection) UpdateAll ¶
func (c *Collection) UpdateAll(selector interface{}, update interface{}, upsert ...bool) (*mongo.UpdateResult, error)
UpdateAll updates multiple documents in the collection.
func (*Collection) UpdateID ¶
func (c *Collection) UpdateID(id interface{}, update interface{}) error
UpdateID updates a single document in the collection by id
func (*Collection) UpdateWithResult ¶
func (c *Collection) UpdateWithResult(selector interface{}, update interface{}, upsert ...bool) (result *mongo.UpdateResult, err error)
UpdateWithResult updates a single document in the collection and returns update result.
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 ¶ added in v0.1.7
CollectionNames returns the collection names present in database.
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) Limit ¶
Limit specifies a limit on the number of results. A negative limit implies that only 1 batch should be returned.
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.
func (*Session) SetPoolLimit ¶
SetPoolLimit specifies the max size of a server's connection pool.