Skip to content

Commit cae553b

Browse files
committed
Update README
1 parent 9b1029f commit cae553b

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

README.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,48 @@
99
Simple ODM wraps mgo with interface.
1010

1111
## TODO
12-
- [ ] 0.1.0 release
13-
- [ ] Test coverage
12+
- [x] 0.1.0 release
13+
- [ ] Test cgo getoverage
1414
- [x] Travis-ci support
1515

1616
## Limits
1717

18-
Do not support complex mongo qurey for now.
18+
Do not support complex mongo query for now.
1919

20-
More need discovery :/.
20+
More limits need to discovery :D
2121

2222
## Usage
2323

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+
```

0 commit comments

Comments
 (0)