I am using Quasar and JavaScript with a Dexie Database. I’m trying to export only certain items from the database.
My application has events that contain trials. I have an event table and a trial table. (also more tables, but for now this will be enough) The database is getting pretty large with all the events, so I want to be able to export the events with the related trial information from the trial table so they can be stored. Then eventually delete those events and trials.
I’m using the following:
import "dexie-export-import"
import { exportDB } from "dexie-export-import"
import download from 'downloadjs'
I have a select field which allows the user select which event to export. Then I run it through the exportDB and download the file. This works fine:
const getStuffToExport = await exportDB(pawTapDB, {
prettyJson: true
filter: (table, value, key) => table === "trialTable",
})
download(getStuffToExport, "PawTapBackupFile.json", "application/json")
This gets the entire table. But I only want data that contains the event from the selection. This is a snippet from the JSON file that is being downloaded/exported:
{
"tableName": "trialTable",
"inbound": true,
"rows": [
{
"fk_event": 1,
"trialNum": 1,
"trialDate": "2022-06-04",
"trialEventNumber": "2022745113",
"buried": {
"buriedNoviceOffered": true,
"buriedNoviceJudge": 3,
.....
What I need to do is filter it further so that I get only the table entries that have the fk_event that I am looking for. So for example I only want the table rows where the fk_event == 1.
Is this possible?
In the filter function in Dexie it has three values: table, value, key. I’m not actually sure what the value and the key is. I can’t find an example of those anywhere. The table is, obviously, the table name. Can I use value or key to further reduce my selection?
Thanks