Dexie.js icon indicating copy to clipboard operation
Dexie.js copied to clipboard

where with multiple column and anyof()

Open hiren-jarvisbitz opened this issue 2 years ago • 3 comments

I have table data as mentioned below. Id Name Type 1 ABC SCAN 2 BDC SCAN 3 ABC MANUAL 4 BDC EXTDEV 5 ABC EXTDEV

As per the above Tbl data want ABC data including all 3 types.

I have tried below function export const getInventoryScanProductByAccNameAndType = async ( accName ) => await db.InventoryScans .where(['AccountName', 'ProductEnterType']).anyOf(accName, ['SCAN', 'MANUAL', 'EXTDEVICE']).toArray();

Can anyone help me to get the data below?

Id Name Type 1 ABC SCAN 2 ABC MANUAL 3 ABC EXTDEV

hiren-jarvisbitz avatar Jun 17 '22 13:06 hiren-jarvisbitz

Given your table has an index '[AccountName+ProductEnterType]':

await db
  .InventoryScans
  .where('[AccountName+ProductEnterType]')
  .anyOf([accName, 'SCAN'], [accName, 'MANUAL'], [accName, 'EXTDEVICE'])
  .toArray();

dfahlander avatar Jun 17 '22 21:06 dfahlander

thanks a lot. Your answer is very helpful for me.

hiren-jarvisbitz avatar Jun 20 '22 08:06 hiren-jarvisbitz

Thanks for the above query. This was very helpful to get the data I want.

hiren-jarvisbitz avatar Jun 20 '22 11:06 hiren-jarvisbitz