Documentation ¶
Index ¶
- Variables
- func AndQuery(qs []bson.M) bson.M
- func BsonM2Struct(m bson.M, s interface{}) (status bool)
- func CaseInsensitiveQuery(value interface{}) bson.M
- func FuzzyQuery(value interface{}) bson.M
- func InQuery(valueList interface{}) bson.M
- func IsObjectIdHex(s string) bool
- func NExistQuery() bson.M
- func NewObjectId() bson.ObjectId
- func NinQuery(valueList interface{}) bson.M
- func NotQuery(value interface{}) bson.M
- func OrQuery(qs []bson.M) bson.M
- func SafeToObjectId(s string) (bson.ObjectId, error)
- func SafeToObjectIdOrEmpty(s string) bson.ObjectId
- func SetOperator(value interface{}) bson.M
- func SizeQuery(size int) bson.M
- func ToObjectIdHex(s string) bson.ObjectId
- type Auth
- type Client
- func (client *Client) All(coll string, query bson.M, selector bson.M, results interface{}) error
- func (client *Client) AllSorted(coll string, query bson.M, sort []string, selector bson.M, results interface{}) error
- func (client *Client) BulkUpdate(coll string, pairs []interface{}) (err error)
- func (client *Client) Close()
- func (client *Client) Count(coll string, query bson.M) (int, error)
- func (client *Client) Exists(coll string, query bson.M) bool
- func (client *Client) Insert(coll string, data interface{}) error
- func (client *Client) Iter(coll string, query bson.M, out chan bson.M) error
- func (client *Client) NewMongoAutoCommiter(coll string) *MongoAutoCommitBuilder
- func (client *Client) One(coll string, query bson.M, result interface{}) error
- func (client *Client) Remove(coll string, query bson.M) error
- func (client *Client) Search(coll string, query bson.M, sort []string, offset int, size int, ...) error
- func (client *Client) Spawn() (sub *Client)
- func (client *Client) Update(coll string, query bson.M, update interface{}) error
- func (client *Client) UpdateAll(coll string, query bson.M, update interface{}) (err error)
- func (client *Client) Upsert(coll string, query bson.M, update interface{}) error
- func (client *Client) UseDB(db string) *Client
- type MongoAutoCommitBuilder
- func (s *MongoAutoCommitBuilder) BulkActions(bulkActions int) *MongoAutoCommitBuilder
- func (s *MongoAutoCommitBuilder) Collection(coll string) *MongoAutoCommitBuilder
- func (s *MongoAutoCommitBuilder) FlushInterval(interval time.Duration) *MongoAutoCommitBuilder
- func (s *MongoAutoCommitBuilder) Name(name string) *MongoAutoCommitBuilder
- func (s *MongoAutoCommitBuilder) Start() (mac *MongoAutoCommitter, err error)
- func (s *MongoAutoCommitBuilder) Verbose(verbose bool) *MongoAutoCommitBuilder
- func (s *MongoAutoCommitBuilder) Workers(num int) *MongoAutoCommitBuilder
- type MongoAutoCommitter
- func (p *MongoAutoCommitter) Close() error
- func (p *MongoAutoCommitter) Flush() error
- func (p *MongoAutoCommitter) Insert(doc interface{}) (e error)
- func (p *MongoAutoCommitter) Start() error
- func (p *MongoAutoCommitter) Stop() error
- func (p *MongoAutoCommitter) Update(pair []interface{}) (e error)
- func (p *MongoAutoCommitter) Upsert(pair []interface{}) (e error)
Constants ¶
This section is empty.
Variables ¶
var (
MongoBatchSize = 2000
)
Functions ¶
func BsonM2Struct ¶
m bson.M s SomeStruct BsonM2Struct(m, &s)
func CaseInsensitiveQuery ¶
func FuzzyQuery ¶
func IsObjectIdHex ¶
func NExistQuery ¶
func SafeToObjectIdOrEmpty ¶
func SetOperator ¶
func ToObjectIdHex ¶
Types ¶
type Auth ¶
*
- Database is the default database name used when the Session.DB method
- is called with an empty name, and is also used during the initial
- authentication if Source is unset. *
- Username and Password inform the credentials for the initial authentication
- done on the database defined by the Source field. See Session.Login. *
func (*Auth) UpdateDialInfo ¶
func (auth *Auth) UpdateDialInfo(info *mgo.DialInfo)
type Client ¶
type Client struct { Session *mgo.Session Db string // contains filtered or unexported fields }
func NewMongoClient ¶
func NewMongoClient(addrs []string, db string, timeout time.Duration, auth *Auth) (client *Client, err error)
*
* * Addrs holds the addresses for the seed servers. * * Database is the default database name used when the Session.DB method * is called with an empty name, and is also used during the initial * authentication if Source is unset. * * Username and Password inform the credentials for the initial authentication * done on the database defined by the Source field. See Session.Login. * * Timeout is the amount of time to wait for a server to respond when * first connecting and on follow up operations in the session. If * timeout is zero, the call may block forever waiting for a connection * to be established. Timeout does not affect logic in DialServer.
func (*Client) BulkUpdate ¶
func (*Client) Insert ¶
Insert inserts one or more documents in the respective collection. In case the session is in safe mode (see the SetSafe method) and an error happens while inserting the provided documents, the returned error will be of type *LastError.
func (*Client) NewMongoAutoCommiter ¶
func (client *Client) NewMongoAutoCommiter(coll string) *MongoAutoCommitBuilder
func (*Client) Upsert ¶
Upsert finds a single document matching the provided selector document and modifies it according to the update document. If no document matching the selector is found, the update document is applied to the selector document and the result is inserted in the collection. If the session is in safe mode (see SetSafe) details of the executed operation are returned in info, or an error of type *LastError when some problem is detected.
Relevant documentation:
http://www.mongodb.org/display/DOCS/Updating http://www.mongodb.org/display/DOCS/Atomic+Operations
type MongoAutoCommitBuilder ¶
type MongoAutoCommitBuilder struct {
// contains filtered or unexported fields
}
*
*
func (*MongoAutoCommitBuilder) BulkActions ¶
func (s *MongoAutoCommitBuilder) BulkActions(bulkActions int) *MongoAutoCommitBuilder
BulkActions specifies when to flush based on the number of actions currently added. Defaults to 1000 and can be set to -1 to be disabled.
func (*MongoAutoCommitBuilder) Collection ¶
func (s *MongoAutoCommitBuilder) Collection(coll string) *MongoAutoCommitBuilder
Collection defined the target coll
func (*MongoAutoCommitBuilder) FlushInterval ¶
func (s *MongoAutoCommitBuilder) FlushInterval(interval time.Duration) *MongoAutoCommitBuilder
func (*MongoAutoCommitBuilder) Name ¶
func (s *MongoAutoCommitBuilder) Name(name string) *MongoAutoCommitBuilder
Name is an optional name to identify this bulk processor.
func (*MongoAutoCommitBuilder) Start ¶
func (s *MongoAutoCommitBuilder) Start() (mac *MongoAutoCommitter, err error)
func (*MongoAutoCommitBuilder) Verbose ¶
func (s *MongoAutoCommitBuilder) Verbose(verbose bool) *MongoAutoCommitBuilder
func (*MongoAutoCommitBuilder) Workers ¶
func (s *MongoAutoCommitBuilder) Workers(num int) *MongoAutoCommitBuilder
Workers is the number of concurrent workers allowed to be executed. Defaults to 1 and must be greater or equal to 1.
type MongoAutoCommitter ¶
type MongoAutoCommitter struct {
// contains filtered or unexported fields
}
func (*MongoAutoCommitter) Close ¶
func (p *MongoAutoCommitter) Close() error
Close stops the bulk processor previously started with Do. If it is already stopped, this is a no-op and nil is returned.
By implementing Close, BulkProcessor implements the io.Closer interface.
func (*MongoAutoCommitter) Flush ¶
func (p *MongoAutoCommitter) Flush() error
Flush manually asks all workers to commit their outstanding requests. It returns only when all workers acknowledge completion.
func (*MongoAutoCommitter) Insert ¶
func (p *MongoAutoCommitter) Insert(doc interface{}) (e error)
Add adds a single request to commit by the BulkProcessorService.
The caller is responsible for setting the index and type on the request.
func (*MongoAutoCommitter) Start ¶
func (p *MongoAutoCommitter) Start() error
func (*MongoAutoCommitter) Stop ¶
func (p *MongoAutoCommitter) Stop() error
Stop is an alias for Close.
func (*MongoAutoCommitter) Update ¶
func (p *MongoAutoCommitter) Update(pair []interface{}) (e error)
Add adds a single request to commit by the BulkProcessorService.
The caller is responsible for setting the index and type on the request.
func (*MongoAutoCommitter) Upsert ¶
func (p *MongoAutoCommitter) Upsert(pair []interface{}) (e error)
Add adds a single request to commit by the BulkProcessorService.
The caller is responsible for setting the index and type on the request.