-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to page? #14
Comments
Sure. The query() portion is likely what you are looking for.
See https://github.com/bramski/angular-indexedDB/blob/master/angular-indexed-db.js#L660 |
Hi bramski, $indexedDB.openStore("foo", function (fooStore) {
query = fooStore.query();
store.findWhere(query.$index("id").$lt(5)).then( function (limitedObjects) {
//do some stuff with the items...
});
}); Overall this solution works well for an index that works like a sql sequence but suppose you have and index for a property like "name", I would like to use the library in order to retrieve the top 5 results and not the records with the property "name" between "a" and "b". With the IDBCursor I could use the advance() function [http://www.w3.org/TR/IndexedDB/#widl-IDBCursor-advance-void-unsigned-long-count]. Best regards |
Right now the library does not give you access to the "continue" function of the cursor and to do essentially a "limit". I don't see that as particularly difficult but it would have to be implemented in the internals of the library. You are welcome to fork and work on this change if it is something you need. Below is a link to the function you would need to work with to make this happen. Right now what occurs is that a "cursor" is opened and it is simply iterated until exhaustion. You could simply provide a "limit" to reduce your number of results. https://github.com/bramski/angular-indexedDB/blob/master/src/angular-indexed-db.coffee#L217 Typically a paging solution needs an "offset" though so a proper limit would have to use a known value to begin the query from. Cheers! |
Closing this. Feel free to re open if your question isn't addressed. |
Hi bramski,
Thanks for your work. I'm new to angularjs and I'm trying to use this useful library in my project. My question is: I know indexeddb use cursor. Can I use it to implement a pagination function with angular-indexedDB library. I didn't found a function to access the cursor.
Best regards
Giuseppe
The text was updated successfully, but these errors were encountered: