1
0
Fork 0
mirror of https://github.com/Luzifer/worktime.git synced 2024-10-18 16:14:21 +00:00
worktime/vendor/github.com/lancecarlson/couchgo
2016-09-24 15:00:03 +02:00
..
.gitignore Vendor deps 2016-09-24 15:00:03 +02:00
couch.go Vendor deps 2016-09-24 15:00:03 +02:00
README.md Vendor deps 2016-09-24 15:00:03 +02:00

couch.go

CouchDB Adapter for Go. Supports BulkSave and emulates couch.js API

API Overview

c := NewClient("http://localhost:5984/myleathercouch")

c.CreateDB()

type Cat struct {
  ID string `json:"_id,omitempty"`
  Rev string `json:"_rev,omitempty"`
  Deleted bool `json:"_deleted,omitempty"`
  Name string
  Cool bool
}

cat := Cat{Name: "Octo", Cool: true}

res, err := c.Save(cat)

if err != nil {
  // Do whatever
}

lazyCat := Cat{}

err := c.Get(res.ID, lazyCat)

fmt.Println(lazyCat)

c.Delete(res.ID, res.Rev)

params := url.Values{"limit": []string{"5"}}
results, err := c.View("myapp", "all", &params, nil)
if err != nil {
   // Do whatever
}

fmt.Println(results)

for _, row := range res.Rows {
  cat := &Cat{}
  couch.Remarshal(row.Value, cat)
  fmt.Println(cat)
}

TODO (Top to bottom priority)

  • _changes
  • Attachments