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?
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 :)
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.