forked from pivotal-pez/cfmgo
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.go
More file actions
36 lines (31 loc) · 1020 Bytes
/
types.go
File metadata and controls
36 lines (31 loc) · 1020 Bytes
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
package cfmgo
import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type (
//Collection - an interface representing a trimmed down collection object
Collection interface {
Wake()
Close()
Find(params Params, result interface{}) (count int, err error)
FindOne(id string, result interface{}) (err error)
UpsertID(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
FindAndModify(selector interface{}, update interface{}, target interface{}) (info *mgo.ChangeInfo, err error)
Count() (int, error)
}
//CollectionRepo - mgo collection adapter
CollectionRepo struct {
Col *mgo.Collection
session *mgo.Session
}
//CollectionDialer - a funciton type to dial for collections
CollectionDialer func(url string, dbname string, collectionname string) (collection Collection, err error)
//Params interface exposes mongodb-specific query parameters: Selector, Scope, Limit, and Offset
Params interface {
Selector() bson.M
Scope() bson.M
Limit() int
Offset() int
}
)