Reputation: 702
Can I use compound indexes with .upperBound and .lowerBound in indexedDb? I have tried and it doesn't seem to work so now I'm just using
//upper bound on the Date, filter for `A`
IDBKeyRange.bound(['A', '9999-12-12'], ['A', new Date()])
//lower bound on the Date, filter for `A`
IDBKeyRange.bound(['A', new Date()], ['A', '0000-01-01'])
Is this a reasonable approach? Or Am I missing something?
Upvotes: 0
Views: 408
Reputation: 18690
I believe you can use compound keys, so, quick guess, but does it have to do with 'literals' being literals and Date objects being date objects?
Edit: to be clearer, I meant that the types must align. '9999-12-12' is not the same type as new Date(). Also, the types must correspond to the type of the property. In the object, 'A' must correspond to a string property. In the object, '9999-12-12' and new Date() both must correspond to a string (or date) property.
So, review the property type in the object. If it is string, change new Date to instead use a string. If it is a date, change '9999-12-12' to a date object.
Upvotes: 1