Search code examples
jquerysafariindexeddbydn-db

How to check if data exists in the index/secondary key


I am using ydn-db as the plugin

I have defined indexes (secondary key) and I want to check if I have any data matching for that index.

suppose I have column3 as the index and I have the value "1001" Is there a way I can get a count/data or something if column3 has the value 1001 in it?


Solution

  • It should be as simple as:

    var kr = ydn.db.KeyRange.only(1001);
    db.count('store name', 'index name', kr)
    

    Or using newer syntax:

    db.from('store name').where('index name', '=', 1001).count().done(...