4

i used nedb in my nodejs app , first of my code is :

var Datastore = require('nedb');
var db = new Datastore({ filename: 'users.db', autoload: true });
db.persistence.setAutocompactionInterval(5);

everything is ok with local host , and database will save every thick in my db file . (Database saved after server restarting) but in heroku server , database is empty !!! i think database saved as in-memory ! (not in my db file !!) Why ?! i want keep my database in my db file in Heroku server !

1 Answers1

6

Heroku dynos have an ephemeral file system, so you shouldn't be trying to save your database there. From the documentation:

During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted.

You'll have a better time adding a MongoDB addon and writing to that instead.

gwcodes
  • 5,632
  • 1
  • 11
  • 20