示例#1
0
func (c *CouchStore) DeleteOne(obj caddyshack.StoreObject) error {
	doc := couchdb.NewDocument(obj.GetKey(), "", c.DbObj)
	_, err := doc.GetDocument()
	if err != nil {
		return err
	}
	return doc.Delete()
}
示例#2
0
func (c *CouchStore) Create(obj caddyshack.StoreObject) (err error) {
	strObj, err := json.Marshal(obj)

	doc := couchdb.NewDocument("", "", c.DbObj)
	err = doc.Create(strObj)
	obj.SetKey(doc.Id)
	return
}
示例#3
0
// The object passed should have CouchWrapperUpdate as an anonymous field containing the details.
func (c *CouchStore) UpdateOne(obj caddyshack.StoreObject) (err error) {
	byteObj, err := json.Marshal(obj)
	doc := couchdb.NewDocument(obj.GetKey(), "", c.DbObj)
	err = doc.Update(byteObj)
	return
}