Documentation
¶
Overview ¶
Package mongo is a generated GoMock package.
Index ¶
- Variables
- func FormatAddr(hosts []string) string
- func SetSlowThreshold(threshold time.Duration)
- type BulkInserter
- type ClosableIter
- type Collection
- type Iter
- type MockIter
- func (m *MockIter) All(result interface{}) error
- func (m *MockIter) Close() error
- func (m *MockIter) Done() bool
- func (m *MockIter) EXPECT() *MockIterMockRecorder
- func (m *MockIter) Err() error
- func (m *MockIter) For(result interface{}, f func() error) error
- func (m *MockIter) Next(result interface{}) bool
- func (m *MockIter) State() (int64, []bson.Raw)
- func (m *MockIter) Timeout() bool
- type MockIterMockRecorder
- func (mr *MockIterMockRecorder) All(result interface{}) *gomock.Call
- func (mr *MockIterMockRecorder) Close() *gomock.Call
- func (mr *MockIterMockRecorder) Done() *gomock.Call
- func (mr *MockIterMockRecorder) Err() *gomock.Call
- func (mr *MockIterMockRecorder) For(result, f interface{}) *gomock.Call
- func (mr *MockIterMockRecorder) Next(result interface{}) *gomock.Call
- func (mr *MockIterMockRecorder) State() *gomock.Call
- func (mr *MockIterMockRecorder) Timeout() *gomock.Call
- type Model
- func (mm *Model) Find(query interface{}) (Query, error)
- func (mm *Model) FindId(id interface{}) (Query, error)
- func (mm *Model) GetCollection(session *mgo.Session) Collection
- func (mm *Model) Insert(docs ...interface{}) error
- func (mm *Model) Pipe(pipeline interface{}) (Pipe, error)
- func (mm *Model) PutSession(session *mgo.Session)
- func (mm *Model) Remove(selector interface{}) error
- func (mm *Model) RemoveAll(selector interface{}) (*mgo.ChangeInfo, error)
- func (mm *Model) RemoveId(id interface{}) error
- func (mm *Model) TakeSession() (*mgo.Session, error)
- func (mm *Model) Update(selector, update interface{}) error
- func (mm *Model) UpdateId(id, update interface{}) error
- func (mm *Model) Upsert(selector, update interface{}) (*mgo.ChangeInfo, error)
- type Option
- type Pipe
- type Query
- type ResultHandler
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = mgo.ErrNotFound
ErrNotFound is an alias of mgo.ErrNotFound.
Functions ¶
func FormatAddr ¶
FormatAddr formats mongo hosts to a string.
func SetSlowThreshold ¶
SetSlowThreshold sets the slow threshold.
Types ¶
type BulkInserter ¶
type BulkInserter struct {
// contains filtered or unexported fields
}
A BulkInserter is used to insert bulk of mongo records.
func NewBulkInserter ¶
func NewBulkInserter(session *mgo.Session, dbName string, collectionNamer func() string) *BulkInserter
NewBulkInserter returns a BulkInserter.
func (*BulkInserter) Flush ¶
func (bi *BulkInserter) Flush()
Flush flushes the inserter, writes all pending records.
func (*BulkInserter) SetResultHandler ¶
func (bi *BulkInserter) SetResultHandler(handler ResultHandler)
SetResultHandler sets the result handler.
type ClosableIter ¶
type ClosableIter struct {
Iter
Cleanup func()
}
A ClosableIter is a closable mongo iter.
type Collection ¶
type Collection interface {
Find(query interface{}) Query
FindId(id interface{}) Query
Insert(docs ...interface{}) error
Pipe(pipeline interface{}) Pipe
Remove(selector interface{}) error
RemoveAll(selector interface{}) (*mgo.ChangeInfo, error)
RemoveId(id interface{}) error
Update(selector, update interface{}) error
UpdateId(id, update interface{}) error
Upsert(selector, update interface{}) (*mgo.ChangeInfo, error)
}
Collection interface represents a mongo connection.
type Iter ¶
type Iter interface {
All(result interface{}) error
Close() error
Done() bool
Err() error
For(result interface{}, f func() error) error
Next(result interface{}) bool
State() (int64, []bson.Raw)
Timeout() bool
}
Iter interface represents a mongo iter.
type MockIter ¶
type MockIter struct {
// contains filtered or unexported fields
}
MockIter is a mock of Iter interface
func NewMockIter ¶
func NewMockIter(ctrl *gomock.Controller) *MockIter
NewMockIter creates a new mock instance
func (*MockIter) EXPECT ¶
func (m *MockIter) EXPECT() *MockIterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockIterMockRecorder ¶
type MockIterMockRecorder struct {
// contains filtered or unexported fields
}
MockIterMockRecorder is the mock recorder for MockIter
func (*MockIterMockRecorder) All ¶
func (mr *MockIterMockRecorder) All(result interface{}) *gomock.Call
All indicates an expected call of All
func (*MockIterMockRecorder) Close ¶
func (mr *MockIterMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close
func (*MockIterMockRecorder) Done ¶
func (mr *MockIterMockRecorder) Done() *gomock.Call
Done indicates an expected call of Done
func (*MockIterMockRecorder) Err ¶
func (mr *MockIterMockRecorder) Err() *gomock.Call
Err indicates an expected call of Err
func (*MockIterMockRecorder) For ¶
func (mr *MockIterMockRecorder) For(result, f interface{}) *gomock.Call
For indicates an expected call of For
func (*MockIterMockRecorder) Next ¶
func (mr *MockIterMockRecorder) Next(result interface{}) *gomock.Call
Next indicates an expected call of Next
func (*MockIterMockRecorder) State ¶
func (mr *MockIterMockRecorder) State() *gomock.Call
State indicates an expected call of State
func (*MockIterMockRecorder) Timeout ¶
func (mr *MockIterMockRecorder) Timeout() *gomock.Call
Timeout indicates an expected call of Timeout
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
A Model is a mongo model.
func MustNewModel ¶
MustNewModel returns a Model, exits on errors.
func (*Model) GetCollection ¶
func (mm *Model) GetCollection(session *mgo.Session) Collection
GetCollection returns a Collection with given session.
func (*Model) PutSession ¶
PutSession returns the given session.
func (*Model) RemoveAll ¶
func (mm *Model) RemoveAll(selector interface{}) (*mgo.ChangeInfo, error)
RemoveAll removes all with given selector and returns a mgo.ChangeInfo.
func (*Model) TakeSession ¶
TakeSession gets a session.
type Option ¶
type Option func(opts *options)
Option defines the method to customize a mongo model.
func WithTimeout ¶
WithTimeout customizes an operation with given timeout.
type Pipe ¶
type Pipe interface {
All(result interface{}) error
AllowDiskUse() Pipe
Batch(n int) Pipe
Collation(collation *mgo.Collation) Pipe
Explain(result interface{}) error
Iter() Iter
One(result interface{}) error
SetMaxTime(d time.Duration) Pipe
}
Pipe interface represents a mongo pipe.
type Query ¶
type Query interface {
All(result interface{}) error
Apply(change mgo.Change, result interface{}) (*mgo.ChangeInfo, error)
Batch(n int) Query
Collation(collation *mgo.Collation) Query
Comment(comment string) Query
Count() (int, error)
Distinct(key string, result interface{}) error
Explain(result interface{}) error
For(result interface{}, f func() error) error
Hint(indexKey ...string) Query
Iter() Iter
Limit(n int) Query
LogReplay() Query
MapReduce(job *mgo.MapReduce, result interface{}) (*mgo.MapReduceInfo, error)
One(result interface{}) error
Prefetch(p float64) Query
Select(selector interface{}) Query
SetMaxScan(n int) Query
SetMaxTime(d time.Duration) Query
Skip(n int) Query
Snapshot() Query
Sort(fields ...string) Query
Tail(timeout time.Duration) Iter
}
Query interface represents a mongo query.
type ResultHandler ¶
type ResultHandler func(*mgo.BulkResult, error)
ResultHandler is a handler that used to handle results.