https://github.com/serkansipahi/corm
Developer friendly ORM for CouchDB written in Golang
https://github.com/serkansipahi/corm
api couchdb database friendly golang helper nosql-database orm rapid testdriven
Last synced: 8 months ago
JSON representation
Developer friendly ORM for CouchDB written in Golang
- Host: GitHub
- URL: https://github.com/serkansipahi/corm
- Owner: SerkanSipahi
- License: other
- Created: 2017-09-12T20:42:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-11T18:14:50.000Z (over 7 years ago)
- Last Synced: 2025-02-14T12:54:39.388Z (8 months ago)
- Topics: api, couchdb, database, friendly, golang, helper, nosql-database, orm, rapid, testdriven
- Language: Go
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CORM
The awesome CouchDB ORM library for Golang, aims to be developer friendly.
[](https://godoc.org/github.com/SerkanSipahi/corm)
[](https://goreportcard.com/report/github.com/SerkanSipahi/corm)## Overview
* Our goal is to adapt/implement the Domain-Classes Methods from [grails](http://docs.grails.org/latest/ref/Domain%20Classes/save.html) and some of the CouchDB specific [Api](https://godoc.org/github.com/flimzy/kivik) for 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.## Requirements
* CouchDB >= 2.1
* Golang >= 1.9## Installation
```golang
go get -u github.com/SerkanSipahi/corm
```### ORM methods (our goal for a Nosql-Database)
#### db methods
```golang
ctx := context.TODO()
db, err := corm.New(ctx, corm.Config{
DBName: "myDatabase",
})
```- [x] [Save](https://godoc.org/github.com/SerkanSipahi/corm#Orm.Save)
- [x] [Read](https://godoc.org/github.com/SerkanSipahi/corm#Orm.Read)
- [x] [Update](https://godoc.org/github.com/SerkanSipahi/corm#Orm.Update)
- [x] [Delete](https://godoc.org/github.com/SerkanSipahi/corm#Orm.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### Basic usage
```golangtype Product struct {
Id string `json:"_id,omitempty"` // required in this style
Rev string `json:"_rev,omitempty"` // required in this style
Type string `json:"type"` // required: tag this but don´t touch it
// additionals
Name string `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
var product Product
_, err = db.Read(ctx, docId, &product)
fmt.Println(product) // product{ Id: "asdfj334234f34asdfq34", Rev: "1-alsj34lkjij3lksife" ...// delete document
rev, err = db.Delete(ctx, docId, rev)
```## Author
**SerkanSipahi**
*
*
*## Contributors
https://github.com/SerkanSipahi/corm/graphs/contributors
## License
This software is released under the terms of the Apache 2.0 license. See LICENCE.md, or read the [full license](http://www.apache.org/licenses/LICENSE-2.0).