WriteableCollection - zuki/Dexie.js GitHub Wiki
Represents a writeable collection of database objects. Note that it will not contain any objects by itself. Instead, it yields a preparation for how to execute a DB query. A query will be executed when calling methods like toArray(), each(), eachKey, eachUniqueKey(), keys() and uniqueKeys().
Inheritance Hierarchy
- Collection
- WriteableCollection
Construction
WriteableCollection constructor is private. Instances are returned from the WhereClause methods and some of the WriteableTable methods.
Sample
// Execute a query that makes all "david" get a canonical casing "David":
db.friends.where("name").equalsIgnoreCase("david").modify({name: "David"});
Methods
delete()
Delete all objects in the collection
modify()
Modify all objects in the collection with given properties or function.
Collection
Methods derived fromand()
Add JS based criteria to collection
count()
Get the number of items in the collection
desc()
Sort in descending order
distinct()
Remove duplicates of items with same primary key
each()
Execute query and call a function for each item
eachKey()
Execute query on the index or primary key being used and call a function for each key
eachUniqueKey()
Execute query on the index or primary key being used and call a function for each unique key
first()
Get the first item in the collection
keys()
Retrieve an array containing all keys of the collection (index or primary key depending on where() clause)
last()
Get the last item in the collection
limit()
Limit the result to given number of items
offset()
Ignore N items before given offset and return the rest
or()
Logical OR operation
reverse()
Reverse the order of items.
sortBy()
Execute query and get an array with the results sorted by given property
toArray()
Execute query and get an array with the results sorted by the index used in the where() clause
uniqueKeys()
Retrieve an array containing all unique keys of the collection (index or primary key depending on where() clause)
until()
Ignores items occurring after given filter returns true.