First of all: thank you for Dexie, it's awesome!
where is really powerfull; nevertheless, it could gain from having a method that just tests whether a field exists or not, similarly to Mongo's $exists method.
For instance, when a given property contains an object, it's not possible (at least to my knowledge) to query all objects that have it. equals doesn't allow this.
I often find myself having to create a separate property that I just use to query and another one that actually contains an object with usefull data:
proptToSync: {} would contain dirty properties that need to be synced with server,needSync: 'true' to query (btw, couldn't equals support booleans? As I find it weird to write true/false as strings).For $exists check out https://github.com/YurySolovyov/dexie-mongoify . It has the operator from what I can tell but I don't know if it does exactly the same an mongodb's $exists.
Equals does not support booleans because indexedDB indexes don't support booleans. Dexie might support booleans in the future. See https://github.com/dfahlander/Dexie.js/issues/427 .
Regarding server synchronization you might want to checkout Dexie.Syncable https://github.com/dfahlander/Dexie.js/tree/master/addons/Dexie.Syncable
You could use
db.yourTable.where('property').aboveOrEqual(-Infinity)
It will find all objects where the property exists and is of any indexable type (number, string, Date or Arrayobject or boolean though since those types aren't indexable.
Thank you both for your prompt and detailed answers.
I love the aboveOrEqual trick. I'll sure have a look at mongoofy too. But from what I've seen, the docs seem poor. Okay, that was on the mobile version, I don't know why.
Most helpful comment
You could use
It will find all objects where the property exists and is of any indexable type (number, string, Date or Array). It wouldn't find propertied of type
objectorbooleanthough since those types aren't indexable.