-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.go
More file actions
54 lines (48 loc) · 1.73 KB
/
Copy pathinterfaces.go
File metadata and controls
54 lines (48 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package mgohttp
import (
mgo "gopkg.in/mgo.v2"
bson "gopkg.in/mgo.v2/bson"
)
// MongoSession wraps a subset of the session interface to Mongo for tracing purposes
type MongoSession interface {
DB(name string) MongoDatabase
Ping() error
}
// MongoDatabase wraps a subset of the Database interface to Mongo for tracing purposes
type MongoDatabase interface {
C(collection string) MongoCollection
Run(cmd interface{}, result interface{}) error
}
// MongoCollection wraps a subset of the Collection interface to Mongo for tracing purposes
type MongoCollection interface {
Find(query interface{}) MongoQuery
FindId(id bson.ObjectId) MongoQuery
Insert(docs ...interface{}) error
Remove(selector interface{}) error
RemoveId(id bson.ObjectId) error
RemoveAll(selector interface{}) (info *mgo.ChangeInfo, err error)
Update(selector interface{}, update interface{}) error
UpdateId(id bson.ObjectId, update interface{}) error
UpdateAll(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
Upsert(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
}
// MongoQuery wraps a subset of the Query interface to Mongo for tracing purposes
type MongoQuery interface {
All(result interface{}) error
Apply(change mgo.Change, result interface{}) (info *mgo.ChangeInfo, err error)
Count() (n int, err error)
Hint(indexKey ...string) MongoQuery
Iter() MongoIter
Limit(n int) MongoQuery
One(result interface{}) (err error)
Select(selector interface{}) MongoQuery
Sort(fields ...string) MongoQuery
}
// MongoIter wraps the non-deprecated methods of an `mgo.Iter` for tracing purposes
type MongoIter interface {
All(result interface{}) error
Close() error
Done() bool
Err() error
Next(result interface{}) bool
}