Am trying to create a user query with Dexie where the user queries the database in their own but i cant get it to work.
<!-- html -->
<div class="window" style="padding-top: 1.5rem;">
<link rel="stylesheet" type="text/css" href="./css/bootstrap-grid.min.css">
<div class="window-content">
<div class="pane-group">
<div class="pane" style="padding:4rem;padding-top: 0 ">
<h3 class="text-center"><u><span class="icon icon icon-code icon-text" style="color:#4e5851;padding-right:1rem "></span>Advanced Queries</u></h3>
<table class="table-striped mb-2">
<thead>
<tr>
<th colspan="3"><input class="form-control" type="" name="query" id="query"></th>
<th style="width:4rem"><button class="btn btn-default" id="run">
<span class="icon icon-search"></span>
</button></th>
</tr>
</thead>
</table>
<div class ="row" style="display: flex" id='display_body'>
</div>
</div>
</div>
</div>
</div>
//script
document.querySelector('#run').addEventListener("click", function(){
const { init_data} = require('../res/reusable');
var db = init_data(Dexie);
let torun = document.querySelector('#query').value;
let mangoArray=torun.split('.')
//console.log('mangoArray');
if (mangoArray.length== '1') {
db[mangoArray[0]].each(item=>{
console.log(item);
});
}else if(mangoArray.length== '2'){
db[mangoArray[0]][mongoArray[1]].each(item=>{
console.log(item);
});
}
});
When i input devices
in input (a table in the dexie database it works)
in full it should run db.devices.each
However i cant get functions to work inside the dexie class. so when i input
devices.orderBy('name')
i get undefined error
//error
Uncaught TypeError: Cannot read property 'each' of undefined
How do i achieve this?