The awesome CouchDB ORM library for Golang, aims to be developer friendly.
- Our goal is to adapt/implement the Domain-Classes Methods fromgrailsand some of the CouchDB specificApifor CouchDb
- Be careful when using. The api can changed. We are in early state.
- If you have some suggestions or concerns please contact us or make a issue ticket.
- CouchDB >= 2.1
- Golang >= 1.9
goget-ugithub.com/SerkanSipahi/corm
ctx:=context.TODO()
db,err:=corm.New(ctx,corm.Config{
DBName:"myDatabase",
})
- Save
- Read
- Update
- Delete
- First
- Last
- Count
- CountBy
- Exists
- BelongsTo
- DeleteMany
- ExecuteQuery
- UpdateAll
- Find
- FindAll
- FindAllBy
- FindAllWhere
- FindBy
- FindWhere
- Get
- GetAll
- HasMany
- HasOne
- List
- ListOrderBy
- Refresh
- SaveAll
- SaveJson
- Sync
- Validate
- Where
- WhereAny
typeProductstruct{
Idstring`json: "_id,omitempty" `// required in this style
Revstring`json: "_rev,omitempty" `// required in this style
Typestring`json: "type" `// required: tag this but don´t touch it
// additionals
Namestring`json: "name" `
}
// init DB
ctx:=context.TODO()
db,err:=corm.New(ctx,corm.Config{
DBName:"myDatabase",
})
// save document with custom Id
docId,rev,err:=db.Save(ctx,Product{
Id:"111-222-333",
Name:"Foo",
})
// save document with auto Id
docId,rev,err=db.Save(ctx,Product{
Name:"Bar",
})
// update document
rev,err=db.Update(ctx,Product{
Id:docId,
Rev:rev,
Name:"Baz",
})
// read document
varproductProduct
_,err=db.Read(ctx,docId,&product)
fmt.Println(product)// product{ Id: "asdfj334234f34asdfq34", Rev: "1-alsj34lkjij3lksife"...
// delete document
rev,err=db.Delete(ctx,docId,rev)
SerkanSipahi
https://github /SerkanSipahi/corm/graphs/contributors
This software is released under the terms of the Apache 2.0 license. See LICENCE.md, or read thefull license.