Closed FuelKubitox closed 2 years ago
Are you creating the datastore from the renderer or the main process?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have the same problem, I create the file in the main process
I have found the issue. I forgot to call the load function on the datastore instance.
Okay I might know what this is all about now. The Datastore.create
call only creates the Datastore
class instance not the file itself nor does it call the nedb
loadDatastore
function (that's what the load
instance method is for). I admit that the documentation doesn't contain this information, only the README. So I will update the documentation to state, that:
Datastore.create
method only creates the Datastore
class instance and does not load the datastore itself.load
instance method doesn't specifically need to be called as it will be called automatically on any operation (ie.: find
, findOne
, etc.) (of course you can still call this method on application startup or whenever but it's not required).The one thing that's a bit unclear is that @FuelKubitox opened the issue due to the datastore file not being created but there is data saved somewhere. This could still be an issue, @JulianLang did the same thing happen to you as well?
@bajankristof No in my case it was really just forgetting to call the load() method :)
I updated the docs regarding the topic and will close this issue for now.
See: https://github.com/bajankristof/nedb-promises/blob/master/docs.md#Datastore+load https://github.com/bajankristof/nedb-promises/blob/master/docs.md#datastorecreatepathoroptions--proxystatic
I have the problem that the database file didnt get created, but my data is saved somewhere.
I use Electron 14.0.0, Windows 10 and Angular 12.4.
When i use
this._datastoreDiary = Datastore.create(path + 'diary.db');
then the file doesnt get created. I already searched on my whole computer for that file, but it does not exist. Instead my data is saved somewhere else. If i restart my electron app my data still exists, but if i change the path, then all data is gone, but there is still no file. Can someone explain me that?