-
-
Notifications
You must be signed in to change notification settings - Fork 641
Table.where()
Start filtering the object store by creating a WhereClause instance.
table.where(indexOrPrimaryKey)
// Dexie 2.0.0:
table.where(keyPathArray: string[]);
table.where({keyPath1: value1, keyPath2: value2, ...});
indexOrPrimaryKey: String | Name of an index or primary key registered in Version.stores(). The special string ":id" represents the primary key. |
keyPathArray | Strings identifying keyPath to filter on |
keyPath1, keyPath2, ... | Strings identifying keyPath to filter on |
value1, value2, ... | Values to match |
If a string, or array of strings was provided (indexes or primary keys), this method returns a WhereClause based on given index(es) or primary key(s). The returned WhereClause can be used to build a query on how to extract objects from the database using any of the methods in WhereClause. An array of strings represents [compound indexes](Compound Index).
If a plain object containing criterias was provided, this method returns a Collection filtered using given criterias. If providing a single criteria, the keyPath must match with an index. If providing multiple criterias, it is recommended to have a [compound index](Compound Index) containing all of the keyPath (in arbritary order), but it is not required. If no [compound index](Compound Index), at least one of the keyPaths must match a simple index. If Dexie.debug=true and not having compound index of all provided keyPaths, a console.warn() will give a hint on how to index this query properly.
WhereClause if string was provided
Collection if object was provided.
db.friends.where("name").equalsIgnoreCase("david").each(function (friend) {
console.log("Found: " + friend.name + ". Phone: " + friend.phoneNumber);
}).catch(function (error) {
console.error(error);
});
db.friends.where({name: "David"}).each(friends => {
console.log("Found: " + friend.name + ". Phone: " + friend.phoneNumber);
}).catch(error => {
console.error(error.stack || error);
});
Dexie.js - minimalistic and bullet proof indexedDB library