File tree 1 file changed +37
-5
lines changed
1 file changed +37
-5
lines changed Original file line number Diff line number Diff line change 9
9
Simple ODM wraps mgo with interface.
10
10
11
11
## TODO
12
- - [ ] 0.1.0 release
13
- - [ ] Test coverage
12
+ - [x ] 0.1.0 release
13
+ - [ ] Test cgo getoverage
14
14
- [x] Travis-ci support
15
15
16
16
## Limits
17
17
18
- Do not support complex mongo qurey for now.
18
+ Do not support complex mongo query for now.
19
19
20
- More need discovery :/.
20
+ More limits need to discovery : D
21
21
22
22
## Usage
23
23
24
- Please check ` examples/ ` .
24
+ ``` go
25
+ type user struct {
26
+ ID bson.ObjectId ` bson:"_id,omitempty"`
27
+ Name string ` bson:"name"`
28
+ LastIP string ` bson:"last_ip"`
29
+ LastTime time.Time ` bson:"last_time"`
30
+ }
31
+
32
+ type userSelector struct {
33
+ ID *bson.ObjectId ` bson:"_id"`
34
+ IDs *[]bson.ObjectId ` bson:"_id"`
35
+ Name *string ` bson:"name"`
36
+ }
37
+
38
+ func (us *userSelector ) Database () string {
39
+ return " test"
40
+ }
41
+
42
+ func (us *userSelector ) Collection () string {
43
+ return " users"
44
+ }
45
+
46
+ func main () {
47
+ sess , err := mgo.DialWithTimeout (" 127.0.0.1" , 2 *time.Second )
48
+ if err != nil {
49
+ panic (err)
50
+ }
51
+ store := mongo.NewStorage (sess)
52
+ err = store.Query (&userSelector{}).Insert (user{Name: " hello" })
53
+ if err != nil {
54
+ panic (err)
55
+ }
56
+ ` ` `
You can’t perform that action at this time.
0 commit comments