db.read() not working properly?
Gustiviy opened this issue · comments
From my understanding read() is supposed to read the file, and put it into db
, but using console.log
shows the old values.
{ "users": [ { "tag": "user#1111", "point": 4 }] }
This is the JSON file (it has multiple entries but that's not the point)
db.data.users[i].point += 1; db.write(); db.read();
(i is from the for loop filter)
This does change the JSON file, however db
still has the old number. ({ tag: 'user#1111', point: 3 }
)
Could you post a bit more code?
For example, if you're creating the database with the async stuff, then it's possible that the writing happens later. With the async stuff, the correct code would involve await db.write();
Closing as the issue is old, and issue may have been solved since then. Feel free to reopen if needed 👍