-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1297 from nono/replicator-last-seq
Use the last sequence number in the replicator
- Loading branch information
Showing
4 changed files
with
186 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package couchdb | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
// GetLocal fetch a local document from CouchDB | ||
// http://docs.couchdb.org/en/2.1.1/api/local.html#get--db-_local-docid | ||
func GetLocal(db Database, doctype, id string) (map[string]interface{}, error) { | ||
var out map[string]interface{} | ||
u := "_local/" + url.PathEscape(id) | ||
if err := makeRequest(db, doctype, http.MethodGet, u, nil, &out); err != nil { | ||
return nil, err | ||
} | ||
return out, nil | ||
} | ||
|
||
// PutLocal will put a local document in CouchDB. | ||
// Note that you should put the last revision in `doc` to avoid conflicts. | ||
func PutLocal(db Database, doctype, id string, doc map[string]interface{}) error { | ||
u := "_local/" + url.PathEscape(id) | ||
var out UpdateResponse | ||
if err := makeRequest(db, doctype, http.MethodPut, u, doc, &out); err != nil { | ||
return err | ||
} | ||
doc["_rev"] = out.Rev | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters