Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ipfans committed Mar 6, 2018
2 parents b33db42 + b9f4add commit 3291f06
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 11 deletions.
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,50 @@
Simple ODM wraps mgo with interface.

## TODO
- [ ] 0.1.0 release
- [ ] Test coverage
- [x] 0.1.0 release
- [ ] Test cgo getoverage
- [x] Travis-ci support

## Limits

Do not support complex mongo qurey for now.
Do not support complex mongo query for now.

More need discovery :/.
More limits need to discovery :D

All API design may change in the future until reach 1.0

## Usage

Please check `examples/`.
```go
type user struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Name string `bson:"name"`
LastIP string `bson:"last_ip"`
LastTime time.Time `bson:"last_time"`
}

type userSelector struct {
ID *bson.ObjectId `bson:"_id"`
IDs *[]bson.ObjectId `bson:"_id"`
Name *string `bson:"name"`
}

func (us *userSelector) Database() string {
return "test"
}

func (us *userSelector) Collection() string {
return "users"
}

func main() {
sess, err := mgo.DialWithTimeout("127.0.0.1", 2*time.Second)
if err != nil {
panic(err)
}
store := mongo.NewStorage(sess)
err = store.Query(&userSelector{}).Insert(user{Name: "hello"})
if err != nil {
panic(err)
}
```
262 changes: 262 additions & 0 deletions mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import (
type Storage interface {
Query(Collection) QuerySet
Raw(Collection, bson.M) QuerySet
// Insert(c Collection, docs ...interface{}) error
// Update(filter, update interface{}) error
// UpdateAll(filter, update interface{}) (info *mgo.ChangeInfo, err error)
// Upsert(filter, update interface{}) (info *mgo.ChangeInfo, err error)
// Remove(filter interface{}) error
// RemoveAll(filter interface{}) (info *mgo.ChangeInfo, err error)
}

type mongoStorage struct {
Expand Down

0 comments on commit 3291f06

Please sign in to comment.