An database system with fs, simple and powerfull.
Use the package manager npm or yarn to install this libary. I use yarn for example.
yarn add @zidnigz/fs-db
const SimpleDb = require("fs-db");
var db = new SimpleDb("./database"); //make folder database
var userCollections = db.collection("user"); //create folder collection with a name user in folder database
let user = {
name: "John Doe",
age: 29,
};
let update = {
name: "Ani Wilson",
age: 22,
};
userCollection.insert(user); // Make file in folder user
userCollection.update({ age: 29 }, update); //Update databae
userCollection.find({}); // find all data in collection user
/* Output
[{
name: "Ani Wilson",
age:22
}]
*/
userCollection.findOne({ age: 22 }); // find data in userCollection based on age
/*Output
{
name: "Ani Wilson",
age:22
}
*/
userCollection.remove({ age: 22 }); // Delete database each variabel age