Dexie.js: equals support for boolean?

Created on 31 Dec 2016  路  3Comments  路  Source: dfahlander/Dexie.js

Does the equals function support pure boolean check?

Take the following query,

db.amateur_levels.where('completed').equals(true).count(callback);

it should return 0, however it returns,

[...]Error: Failed to execute 'only' on 'IDBKeyRange': The parameter is not a valid key.[...]

when the query is changed to the following,

db.amateur_levels.where('completed').equals('true').count(callback);
//------------------------------------------^    ^--------------------
// Note the single quotes!

it now displays 0 with, so is there support for true and false?

question

Most helpful comment

As far as I know there is no support for boolean in equals. where() and equals() use indexeddb indexes and those don't support boolean values. As a workaround you could use 1 for true and 0 for false. You could convert those to boolean when you read from db if needed and convert back to number when saved.

All 3 comments

As far as I know there is no support for boolean in equals. where() and equals() use indexeddb indexes and those don't support boolean values. As a workaround you could use 1 for true and 0 for false. You could convert those to boolean when you read from db if needed and convert back to number when saved.

@nponiros thanks for the speedy response, much appreciated. Yep, I was considering using integer flags.

You're welcome :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CasperPas picture CasperPas  路  3Comments

remusao picture remusao  路  3Comments

dfahlander picture dfahlander  路  4Comments

fulltic picture fulltic  路  4Comments

nezcich picture nezcich  路  3Comments