-
Notifications
You must be signed in to change notification settings - Fork 66
Add openCursor(key, primaryKey) and continuePrimaryKey #14
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
Comments
Need to specify what happens if you call I'm updating the experimental impl in Blink to throw |
What should the behavior of
If direction is "prevunique" and the cursor is at r3, Cases:
|
Initial work in a4e4d2b |
Another option is to throw if |
@inexorabletash +1 throw InvalidAccessError |
@yathit do you mean for the object store source case, or for "nextunique" / "prevunique", or both? |
@inexorabletash both cases. |
sgtm! |
In the |
Agree.
Using |
Should we throw if Should we define any special behavior if options are used on a unique index? (I vote no.) |
For posterity, here's how you'd write a fallback if these methods didn't exist: var options = {key: 2, primaryKey: 2};
var req = idx.openCursor(null, 'next', options);
req.onsuccess = function() {
var cursor = req.result;
if (!cursor) return;
if (indexedDB.cmp(cursor.key, options.key) < 0 ||
(indexedDB.cmp(cursor.key, options.key) === 0 &&
indexedDB.cmp(cursor.primaryKey, options.primaryKey) < 0)) {
// if you have continuePrimaryKey but not openCursor(..., options) for some reason
if (cursor.continuePrimaryKey) {
cursor.continuePrimaryKey(options.key, options.primaryKey);
return;
}
// If index key is too low we can jump directly to that.
if (indexedDB.cmp(cursor.key, options.key) < 0) {
cursor.continue();
return;
}
// Otherwise we're stuck iterating until we hit the right primary key.
cursor.continue();
return;
}
// The cursor is positioned at appropriate record - use it!
cursor.continue();
}; |
Should this issue be closed? I'm pretty sure Chrome, Firefox and Safari are shipping this. |
Currently you need to open the cursor against key then maybe call |
Thanks for explaining! I missed that first part. |
https://www.w3.org/Bugs/Public/show_bug.cgi?id=20257
If
primaryKey
is specified in options butkey
is not, throw.The text was updated successfully, but these errors were encountered: