Skip to content

Potential bug when updating json DB #97

Open
@adame21

Description

@adame21

Hi,
So I've been using this package a few days now building a system.
I'm using this package to "cache" SQL table data so I can use it locally later.
It's supposed to update the "cache" weekly, or when the app is restarted.

What the problem is that sometimes when the json file already exists it fails to push the new data giving the error of: "Can't Load Database"
And the inner error of: "SyntaxError: Unexpected end of JSON input"

This gets resolved if I delete the existing files and run it again, but if that's the only fix currently I cant use this very useful package.

Some code example: (this runs everytime the app is started for several tables)

let dataToCache = await knex.raw(`SELECT * FROM [BTS].[dbo].[BTSStatusConv] ORDER BY [BTSStatusConv].SystemID , [BTSStatusConv].StatusID`);

for (let i = 0; i < dataToCache.length; i++) {

 db.push(`/${dataToCache[i].SystemID}_${dataToCache[i].StatusID}`, dataToCache[i]);

}

Am I using this package wrong? Is it an actual bug?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions