-
-
Notifications
You must be signed in to change notification settings - Fork 641
Collection.count()
David Fahlander edited this page May 8, 2014
·
15 revisions
collection.count(callback)
callback: Function | function (count) { } | optional |
count: Number | Number of items in the collection |
If callback is omitted and operation succeeds, returned Promise will resolve with the result of the operation, calling any Promise.then() callback.
If callback is specified and operation succeeds, given callback will be called and the returned Promise will resolve with the return value of given callback.
If operation fails, returned promise will reject, calling any Promise.catch() callback.
If executed on simple queries, the native IDB count() method will be called (fast execution). If advanced queries are used, the implementation have to execute a query to iterate all items and count them manually.
Queries where count() will be fast to execute:
- db.[table].count()
- db.[table].where(index).equals(value).count()
- db.[table].where(index).above(value).count()
- db.[table].where(index).below(value).count()
- db.[table].where(index).between(value).count()
- db.[table].where(index).startsWith(value).count()
- db.[table].where(index).equalsIgnoreCase(value).count()
- db.[table].where(index).startsWithIgnoreCase(value).count()
- db.[table].where(index).anyOf(valueArray).count()
- db.[table].where(index).above(value).and(filterFunction).count()
Dexie.js - minimalistic and bullet proof indexedDB library