summaryrefslogtreecommitdiff
path: root/designs/syncs.json
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2013-12-20 12:58:53 +0100
committerAzul <azul@riseup.net>2013-12-20 12:58:53 +0100
commitd8c28a0c3cba76fadd0495a79f67efd61458218c (patch)
treec27c399511c17f6accaad20d906d1ea809857920 /designs/syncs.json
parentf47712d803811f06b4371f50fabdfc1fefffe4cc (diff)
add design docs to be included in each user database
Also strip the .json extention because soledad does not expect it
Diffstat (limited to 'designs/syncs.json')
-rw-r--r--designs/syncs.json11
1 files changed, 11 insertions, 0 deletions
diff --git a/designs/syncs.json b/designs/syncs.json
new file mode 100644
index 0000000..0df5ff7
--- /dev/null
+++ b/designs/syncs.json
@@ -0,0 +1,11 @@
+{
+ "views" : {
+ "log" : {
+ "map" : "function(doc) {\n if (doc._id == 'u1db_sync_log') {\n if (doc.syncs)\n doc.syncs.forEach(function (entry) {\n emit(entry[0],\n {\n 'known_generation': entry[1],\n 'known_transaction_id': entry[2]\n });\n });\n }\n}\n"
+ }
+ },
+ "_id" : "_design/syncs",
+ "updates" : {
+ "put" : "function(doc, req){\n if (!doc) {\n doc = {}\n doc['_id'] = 'u1db_sync_log';\n doc['syncs'] = [];\n }\n body = JSON.parse(req.body);\n // remove outdated info\n doc['syncs'] = doc['syncs'].filter(\n function (entry) {\n return entry[0] != body['other_replica_uid'];\n }\n );\n // store u1db rev\n doc['syncs'].push([\n body['other_replica_uid'],\n body['other_generation'],\n body['other_transaction_id']\n ]);\n return [doc, 'ok'];\n}\n\n"
+ }
+}