Views hidden data

views

#1

I did create two views with different keys, one by email other by sessionToken but when enabling the second view I lost two registers and I deleted the sessionToken view and recover the register in my first view.

Code View employerDataDAO:

function(doc, meta) {
    var sync = doc._sync;
    if (sync === undefined || meta.id.substring(0, 6) == "_sync:")
        return;
    if ((sync.flags & 1) || sync.deleted)
        return;
    delete doc._sync;
    meta.rev = sync.rev;

    if (doc.type && doc.type == "EmployerDataDAO") {
        emit(doc.email.toLowerCase(), doc, meta);
    }
    doc._sync = sync;
}

Code View sessionToken:

function(doc, meta) {
    var sync = doc._sync;
    if (sync === undefined || meta.id.substring(0, 6) == "_sync:")
        return;
    if ((sync.flags & 1) || sync.deleted)
        return;
    delete doc._sync;
    meta.rev = sync.rev;

    if (doc.type && doc.type == "EmployerDataDAO" && doc.devices) {
      for(i = 0; i < doc.devices.length; i++){  
        doc._rev = meta.rev;
      	emit(doc.devices[i].sessionToken, doc, meta);
      }
    }
    doc._sync = sync;
}

Screen one view

Screen two views


#2

I review the information and clear data and working. thanks