1.0.9 • Published 4 years ago
file-based-database-asadbek v1.0.9
Introduction
- Create your javascript file
- Import package:
const Database = require("file-based-database-asadbek");
Install
npm install file-based-database-asadbek
yarn add file-based-database-asadbek
How to use?
Creating new Database
const Database = require("file-based-database-asadbek");
let db = new Database("project_name", __dirname); // first argument should be your project name (string), second argument should be __dirname(don't change it);
The database looks like this:
{
"users": [
{
id: 1,
name: Asadbek,
age: 19,
langs: ["english", "korean", "uzbek", "russian"]
} // ...
]
}
Main functions
There are 6 main functions to use
You should call functions like this:
(async function () {
// here goes functions
await db.createUser(name, age, langs);
})();
(async function () {
// 1
await db.createUser(name, age, langs);
// 2
await db.select(key, value); // you can select users by keyword and its value
// 3
await db.filter(obj); // you should call this function with argument wich is should be an object, and output will be as an array which contains founded users as object
// 4
await db.addLang(lang); // this function takes one argument as a language and will add this language to users informations
// 5
await db.deleteUser(key, value); // This function also works like select function, but this one deletes founded users from array
// 6
await db.rmDb(); // this function don't requires any argument. After calling this function the folder which is created by using new db() will be deleted from your project folder
})();