X
X
xcuube2020-06-30 14:08:39
Node.js
xcuube, 2020-06-30 14:08:39

Node-webkit - how to set up work with NeDB?

Hello! Help, please, to understand.

I have an application on node-webkit, I use NeDB as a data store, when testing everything works fine, the data is read and saved, but as soon as I convert my project to an .exe file, with each new launch of this .exe file, the past launch changes disappear.

I added the output of the current directory at startup and realized that with each new start it changes, example:

4 Runs of the same file and 4 paths:

C:\Users\3EC2~1\AppData\Local\Temp\nw9780_1552287777
C:\Users\3EC2~1\AppData\Local\Temp\nw17252_332861828
C:\Users\3EC2~1\AppData\Local\Temp\nw14276_1631923880
C:\Users\3EC2~1\AppData\Local\Temp\nw7440_937450108


The question is how to keep everything in one place, without prescribing absolute paths (desirable)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xcuube, 2020-06-30
@xcuube

Decided to do it myself:

let fullPath = process.execPath;
let basename = path.basename(fullPath);
let partOfDBFolder = fullPath.replace(basename, '');

this.cards_db = new Datastore({ filename: partOfDBFolder+'/db/cards' });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question