Simple package to help you store and retrieve data from a json file in a simple way. It also allows you to cache data.
For the lazy people like me, who don't want to write a lot of code to store and retrieve data from a json file or caching data.
npm install data-buddy
pnpm install data-buddy
yarn add data-buddy
import { File } from 'data-buddy/file';
const file = new File();
//or if you want to specify a base path
const file = new File("path/to");
file.create({
path: "data", //path to the file (if base path is specified, this will be added to it)
filename: "best_buddy", //name of the file
data: { name: "buddy" } //data to store
});
file.read({
path: "data", //path to the file
filename: "best_buddy" //name of the file
});
file.update({
path: "data", //path to the file
filename: "best_buddy", //name of the file
data: { name: "buddy" } //data to store
});
file.delete({
path: "data", //path to the file
filename: "best_buddy" //name of the file
});
import { Cache } from 'data-buddy/cache';
const cache = new Cache();
await cache.get("key");
await cache.set("key", "value");
//cache with expiration time
await cache.set("key", "value", 1000); //time in ms
cache.delete("key");
cache.clear();
cache.has("key");
cache.all();
Because if you're here, it's probably because you're lazy like me and don't want to write a lot of code to store and retrieve data from a json file or caching data.
If you want to store a lot of data, it's better to use a database.
Yes, since this package has been made from a personal need to learn how to publish a package on npm, I'm open to any contributions to improve it !
You can simply open an issue or a pull request. (No template for now but if you want to add one, feel free to share it !)
MIT