diff options
author | drebs <drebs@leap.se> | 2013-12-04 13:42:59 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-12-18 14:36:54 -0200 |
commit | ae2894ba47ee5bc905f298db6b67ae40af6ebd74 (patch) | |
tree | a39621d9249b12756559bf213ab7e04df6e12ef5 /common/src/leap/soledad/common/ddocs/transactions/lists/whats_changed.js | |
parent | 3a5f090e79c65c063fbe2428248b34c1f43b914f (diff) |
Make couch backend consistent and lightweight.
This commit introduces the use of couch view, list and update functions to put
and get data from the couch database. This avoids loads of metadata
transferring and encapsulates operations in atomic PUTs.
Diffstat (limited to 'common/src/leap/soledad/common/ddocs/transactions/lists/whats_changed.js')
-rw-r--r-- | common/src/leap/soledad/common/ddocs/transactions/lists/whats_changed.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/src/leap/soledad/common/ddocs/transactions/lists/whats_changed.js b/common/src/leap/soledad/common/ddocs/transactions/lists/whats_changed.js new file mode 100644 index 00000000..b35cdf51 --- /dev/null +++ b/common/src/leap/soledad/common/ddocs/transactions/lists/whats_changed.js @@ -0,0 +1,22 @@ +function(head, req) { + var row; + var gen = 1; + var old_gen = 0; + if (req.query.old_gen) + old_gen = parseInt(req.query['old_gen']); + send('{"transactions":[\n'); + // fetch all rows + while(row = getRow()) { + if (gen > old_gen) { + if (gen > old_gen+1) + send(',\n'); + send(JSON.stringify({ + "generation": gen, + "doc_id": row["id"], + "transaction_id": row["value"] + })); + } + gen++; + } + send('\n]}'); +} |