-
-
Notifications
You must be signed in to change notification settings - Fork 649
Collection.count()
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 IndexedDB ObjectStore count()
method will be called (fast execution). If advanced queries are used, the implementation has to execute a query to iterate all items and count them manually.
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(a,b).count()
db.[table].where(index).startsWith(value).count()
The reason it is fast in above samples is that they map to basic IDBKeyRange
methods only()
, lowerBound()
, upperBound()
, and bound()
.
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()
db.[table].where(index1).above(value1).or(index2).below(value2).count()
Dexie.js - minimalistic and bullet proof indexedDB library