treojs / treo

Consistent API to IndexedDB
http://treojs.com
MIT License
257 stars 18 forks source link

FindIn plugin example fails when at least 2 keys being looked for are smaller than the smallest key in the db #40

Open randalpinto opened 8 years ago

randalpinto commented 8 years ago

If you have let's say "2013", "2014", "2015" in the database and if you search for ["2011", "2012"] the plugin fails as it goes into:

if (cursor.key > keys[current]) { result.push(undefined); // key not found current += 1; cursor.continue(keys[current]); }

and then it tries to execute:

cursor.continue("2012") but the current cursor position is "2013" so the operation returns an error.

Granted it is just an example but it was a useful operation for me and I found the issue while trying to use it. I'd vote for it to become an official plugin as large lookups are a lot faster performed like this.

alekseykulikov commented 8 years ago

Thank you for bug report. I will probably implement it as a standalone plugin, since it's indeed quite useful.