-
-
Notifications
You must be signed in to change notification settings - Fork 677
Table.offset()
Returns a Collection (ordered by primary key), where the first N items in the object store are ignored.
db.[table].offset(N)
N: Number | A positive (or zero) Number specifying how many records to ignore |
Return a collection when the first N entries in the object store are ignored. If it is requested to skip the LAST N entires rather than the first, this method can be used in combination with the Collection.reverse() method.
This method is equivalent to:
db.[table].toCollection().offset(N)
or:
db.[table].orderBy(':id').offset(N)
This sample will sort friends by lastName and include the last 15th to 10th friend.
db.friends.orderBy('lastName').reverse().offset(10).limit(5);
In combination with the or() method, the offset() method makes no sense since the sort order of the result will be undefined (or() is working on multuple different indexes in parallell). Instead, use sortBy() and then slice the resulting array from requested offset.
If executed on simple queries, the native IDBCursor.advance() method will be used (fast execution). If advanced queries are used, the implementation have to execute a query to iterate all items and ignore N items using a JS filter.
- db.[table].offset(N)
- db.[table].where(index).equals(value).offset(N)
- db.[table].where(index).above(value).offset(N)
- db.[table].where(index).below(value).offset(N)
- db.[table].where(index).between(value).offset(N)
- db.[table].where(index).startsWith(value).offset(N)
- db.[table].where(index).equalsIgnoreCase(value).offset(N)
- db.[table].where(index).startsWithIgnoreCase(value).offset(N)
- db.[table].where(index).anyOf(valueArray).offset(N)
- db.[table].where(index).above(value).and(filterFunction).offset(N)
Dexie.js - minimalistic and bullet proof indexedDB library