Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where Clause on Compound Index Produces "not indexed" Error

Tags:

dexie

I have the following table schema:

db.version(1).stores({
    sales: "[item_id+date],sales"
});

Where the combination of date and item_id must be unique. How can I get all the records for a given item_id using the where clause (disregarding the date)?

The following produces an error:

db.sales.where('item_id').equals(some_item_id)

Unhandled rejection: SchemaError: KeyPath item_id on object store sales is not indexed

like image 404
Yoav Kadosh Avatar asked Oct 15 '25 17:10

Yoav Kadosh


1 Answers

db.sales.where('[item_id+date]').between ([some_item_id, -Infinity], [some_item_id, Dexie.maxKey])
like image 170
David Fahlander Avatar answered Oct 19 '25 15:10

David Fahlander