When executing a query with multiple filters on an indexed key, execution will return wrong results if the index has include keys, or crash with an TypeError: Cannot read properties of undefined (reading '[key]') if the index has no include keys.
Example:
await db.indexes.create('meteorites', 'name'); // Create index on name, no additional included keys
const snaps = await db.query('meteorites')
.filter('name', '!like', 'L*')
.filter('name', '!=', 'Acapulco') // Another filter on name causes the crash
.get();
This is caused by initial index results being filtered on metadata (include) filters, but the index' key is (obviously) not in the metadata. Solution: filter index results on the indexed value if key equals index.key
When executing a query with multiple filters on an indexed key, execution will return wrong results if the index has include keys, or crash with an
TypeError: Cannot read properties of undefined (reading '[key]')if the index has no include keys.Example:
This is caused by initial index results being filtered on metadata (include) filters, but the index' key is (obviously) not in the metadata. Solution: filter index results on the indexed value if key equals index.key