summaryrefslogtreecommitdiff
path: root/common/src/leap/soledad/common/ddocs/syncs/views/state/map.js
blob: e88c6ebb2868e9dec3893eeb61b3f551c9db33de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function(doc) {
  if (doc['_id'] == 'u1db_sync_state' && doc['ongoing_syncs'] != null)
    for (var source_replica_uid in doc['ongoing_syncs']) {
      var changes = doc['ongoing_syncs'][source_replica_uid]['changes_to_return'];
      var sync_id = doc['ongoing_syncs'][source_replica_uid]['sync_id'];
      if (changes == null)
        emit([source_replica_uid, sync_id], null);
      else
        emit(
          [source_replica_uid, sync_id],
          {
            'gen': changes['gen'],
            'trans_id': changes['trans_id'],
            'number_of_changes': changes['changes_to_return'].length
          });
    }
}