Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: support batch updates via HTTP #100

Merged
merged 5 commits into from Mar 9, 2017
Merged

WIP: support batch updates via HTTP #100

merged 5 commits into from Mar 9, 2017

Conversation

benoitc
Copy link
Member

@benoitc benoitc commented Mar 9, 2017

now supports batch via HTTP.

A batch is a JSON seent on Post with following headers and similar body:

Headers :

  • x-barrel-write-batch: true
  • x-barrel-async: false

JSON:

{ "updates": [
  { "op": "put", "doc": {}, "rev": "" },
  { "op": "delete", "id": "someid", "rev": "" },
  { "op": "post", "doc": {} }
]}

Response is the following

if Async is true: { "ok" : true }

Or following response

{
  "ok": true,
  "results": [
     {"status": "ok", "id": "docid", "rev": "revid" },
  ]
}

Results can be

{"status": "ok", "id": "docid", "rev": "revid" }
{"status": "error", "reason": "not found" }
{"status": "conflict", "reason": "doc exists" }
{"status": "conflict", "reason": "revision conflic" }

fix #57

instead of expecting a list manage the update batch as a stack on which we are happening the values in order.
now supports batch via HTTP.

A batch is a JSON seent on Post with following headers and similar body:

Headers :

x-barrel-write-batch: true
x-barrel-async: false

JSON:

{ "updated":
  [
     { "op": "put", "doc": {},  "rev": "" },
     { "op": "delete", "id": "someid", "rev": "" },
     { "op": "post", "doc": {} }
  ]
}

Response is the following

if Async is true:

{ "ok" : true }

Or following response

{
   "ok": true,
   "results":
      [
        {"status": "ok", "id": "docid", "rev": "revid" },
        ..
     ]
 }

Results can be

-  {"status": "ok", "id": "docid", "rev": "revid" }
-  {"status": "error", "reason": "not found" }
-  {"status": "conflict", "reason": "doc exists" }
-  {"status": "conflict", "reason": "revision conflic" }
helper to write batches so the HTTP API don't rely on barrel_db. While I'm here, move the json parsing to the batch module.
The batch API also supports attachments.
@benoitc benoitc merged commit bc71a88 into master Mar 9, 2017
@benoitc benoitc deleted the bulk_upload branch March 9, 2017 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant