IndexedDB Filter value in reading

0

I have a simple table with 3 fields. One of them is anot_status and I would like to filter only the records that have 0 in that field.

I'm doing this filter manually, like this:

// Abrir o banco para leitura
var tTrn = oDB.transaction(['rmt_anotacoes'], 'readonly');
// Abrir a tabela que será utilizada
var oStr = tTrn.objectStore('rmt_anotacoes');

oStr.openCursor().onsuccess = function(evt){
    var cCur = evt.target.result;

    // Filtrar o status que estiver zerado
    if (cCur && cCur.value.anot_status == 0){
       // Código....

      cCur.continue();
    }
};

It's working, but I was not able to implement a filter in this field so I did not have to read all the records. How do I make this filter?

    
asked by anonymous 08.08.2018 / 02:19

0 answers