Search code examples
where-clausedexie

Dexie: where clause - cant get it to use a plain object containing criterias


I've been searching trough dexie docs and here on stack but i can't find anything related. I'm new to dexie and it's the end of my work day, probably it's something that I didn't understand correctly (ー_ー)!!

This way it works:

DB['t_menus_' + langAbrev].where('menu_type', 'menu_group').equals('6', '3').toArray();

But this way won't work, why?

let theWhere = {menu_type: '6'};
theWhere['menu_group'] = '3';

DB['t_menus_' + langAbrev].where({menu_type: '6', menu_group: '3'}).toArray());
DB['t_menus_' + langAbrev].where(theWhere).toArray());

The error message: Uncaught TypeError: DB.t_menus_ptg.where(...).toArray is not a function


Solution

  • You need dexie >= 2.0 to use the latter format:

    npm install dexie@^2.0.0-beta.11 --save
    

    Or download from:

    unpkg.com/dexie@^2.0.0-beta.11/dist/dexie.js