Reputation: 113
I have an app deployed on Heroku which relies on persistent information. Since the data is simple enough, I thought the best way to store it would be to read and write a JSON file in the system. However, Heroku resets its dynos every now and then which resets my JSON file back to its original state. I tried to look for services online which store JSON files and found none. I didn't want to use MongoDB, Firebase, or anything similar since those are pretty overkill for the data that I want to store. What would be the easiest way to persist data in this case?
For additional information, the JSON file's layout is simply the following which is why I thought using full-fledged databases were overkill.
{
"count": Number,
"retrieved": [
]
}
Any advice would be greatly appreciated.
Upvotes: 3
Views: 2521
Reputation: 801
JSON Blob might suit but it purges blobs not accessed within 30 days, so you'd need some kind of ping to prevent data loss.
Upvotes: 0
Reputation: 159
I know you said a fully fledged database such as MongoDB would be overkill, but, I highly recommend reconsidering this. An alternative would be some sort of file storage website and while this wouldn't be a "fully fledged database", it would not make things simpler for you as you would need to consider all the extra steps and hacky methods to emulate a database, so in the end you may as well just use a database to avoid these hurdles.
And don't forget once you are set up, you can use MongoDB Atlas (a cloud solution for MongoDB) for many other projects in the future quite easily without going through a lot of the initial set up. Another thing to consider is expandability of your current project, you never know what great ideas you may come up with or what aspects you have not yet considered come up.
Upvotes: 1
Reputation: 791
use localtorage
example
var data = {
"count": Number,
"retrieved": [
]
}
to set
localStorage.setItem('_d', JSON.stringify(data));
var restoredSession = JSON.parse(localStorage.getItem('_d'));
https://developer.mozilla.org/es/docs/Web/API/Window/localStorage
Upvotes: 0