membuat sebuah module pengganti database engine untuk mengelola data secara advance

Overview

banner


Custom badge Custom badge

Custom badge

Donate

Donate

Sosial Media

Custom badge Custom badge Custom badge Custom badge Custom badge Custom badge

Introduction

Custom badge Custom badge Custom badge Custom badge Custom badge

Database atau basis data adalah kumpulan data yang dikelola sedemikian rupa berdasarkan ketentuan tertentu yang saling berhubungan sehingga mudah dalam pengelolaannya. Melalui pengelolaan tersebut pengguna dapat memperoleh kemudahan dalam mencari informasi, menyimpan informasi dan membuang informasi. Seiring berjalannya waktu, pengelolaan database memang cukup rumit bagi orang-orang yang baru terjun kedunia pemrograman. Untuk itu saya membuat module ini agar orang-orang bisa mudah mengelola database mereka dengan fungsi yang mutakhir. Mudah-mudahan bermanfaat dan jangan lupa tekan Star untuk membantu saya terus berkembang...



TESTING

untuk anda yang ingin mencoba perngalaman terbaik menggunakan module ini, silahkan ikuti step berikut ini :

download this source
git clone https://github.com/jefripunza/advance-json-database
install node_modules
npm install

buka file test.js dan ikuti perintah selanjutnya (indonesian language)

running test
node test

// or

npm start


PERSIAPAN

Tidak terlalu rumit untuk inisial awal, cukup copy saja file connection.js nya kedalam project anda lalu di import dan langsung bisa digunakan

key system
_id               = primary key (string|int)
_create_at        = kapan dibuat (timestamp)
_modified_at      = kapan terakhir dirubah (timestamp)
_modified_history = history modifikasi data (array)
_deleted_at       = menghapus sementara data dari list (tidak permanen)
_SEO              = untuk keperluan SEO (integer)


PENGGUNAAN

First Time

import library require and this module

const path = require("path");
const Database = require("path/to/connection");

set file path & initial database

// file path json, if not exist ? auto create file json
const file_path_db = path.join(__dirname, "test.txt"); // test.txt akan otomatis menjadi test.json

// for debug
const defaule_array = [
    {
        nama: "Jefri Herdi Triyanto",
        kelas: "webdev",
        hobi: "ngoding",
    },
    {
        nama: "Jack Unch Paijo",
        kelas: "mlongo",
        hobi: "mancing",
    },
];

//  request argument :
//      file_path_db  = nama file (dir_path + name) dan variabel database
//      default_value = nilai awal jika file database belum ada
//      generate      = membuat _id baru di setiap add data (default : true), true ? generateRandomString : integer auto increments

// Standar init (default)
const database = new Database(file_path_db);

// Standar init + default value (only array)
const database = new Database(file_path_db, defaule_array);

// Standar init + default value (only array) + generate
const database = new Database(file_path_db, defaule_array, true);

// if you want to multiply the table data then make another file connection
const database_user = new Database(file_path_db_user);
const database_post = new Database(file_path_db_post);

CRUD

add data

//  request argument :
//      new_data = (array)

database.add(new_data, result => {
    console.log(result);
});

read all list data (not delete)

console.log(database.read());

read all list data (with delete)

console.log(database.readAll());

read one data

//  request argument :
//      select_data = single _id ? (string|int) : (object) # key => match value
        
// single _id (string|int)
console.log(database.one(key_id));

// multi select (object)  # key => match value
console.log(database.one({
    name: value,
}));

update data

//  ketika merubah maka akan menambahkan 2 meta :
//      _modified_at        = waktu merubah (timestamp)
//      _modified_history   = data sebelumnya (array)

//  request argument :
//      select _id      = _id (string|int) 
//      new_data_object = new data => key => new value

database.update(key_id, {
    description: Database.generateRandomString(30), // function extra to rendom string with length
}, result => {
    console.log(result);
});

delete data (non permanent)

//  request argument :
//      select _id = _id (string|int)

database.delete(key_id, result => {
    console.log(result);
});

delete key from data

//  request argument :
//      select _id = _id (string|int)
//      select key = key yang ada didalam data (array)

database.deleteKey(key_id, [
    "_id", // tidak akan terhapus
    "id",
    "price",
], result => {
    console.log(result);
});

clear all data (dangerous)

// require multiple true (min 3) (for accept secure)

database.clearAllData(true, true, true, result => {
    console.log(result);
});

Length of data

console.log(database.length());

Trash

list trash data

// only displays data that has been temporarily deleted
console.log(database.trash());

Super Function

search engine

//  request argument :
//      select key (object) = pilih key yang value nya ingin di cari

//  keterangan :
//      nilai paling atas adalah score tertinggi dari pencarian
//      atau jika menggunakan addon SEO maka yang paling atas adalah data SEO
 
//  meta result :
//      time        = waktu mencari data pada database (second)
//      score       = nilai pencarian dari isi data (select key -> value)
//      result      = list data dari score terbaik sampai terendah
//      percentage  = nilai rekap dari setiap key yang di select
//      data        = real data

// for test
const keyword = "and or on for in is woman";

// execute
const result = database.search({
    description: keyword,
    title: keyword,
    category: keyword,
});

// default result
console.log(result);

// normal result
console.log(result.result.map(data => {
    return data.data
}));

pagination

//  request argument :
//      show = berapa data yang ingin ditampilkan (int)
//      page = sekarang dihalaman berapa (int)
//      button_page = jumlah alinyemen button (auto alinyemen jika data diakhir) (int)
//          ex  : jika nilainya 2  =   [1] - [2] - [center] - [1] - [2]
//              : jika nilainya 1  =   [1] - [center] - [1]

//  meta pagination :
//      min         = nilai terkecil yang ditampilkan
//      max         = nilai terbesar yang ditampilkan
//      page        = halaman sekarang
//      button      = tombol pagination (auto generate)
//      totalRow    = total dari semua data
//      row         = list data

console.log(database.pagination(show, page, button_page));

Addon

SEO managements

//  request argument :
//      select _id = _id (string|int)
//      nilai SEO = (only integer), range = unlimited integer

// add score SEO
database.addSEO(key_id, score, result => {
    console.log(result);
});

// list SEO only
console.log(database.listSEO());

// update score SEO
database.updateSEO(key_id, score, result => {
    console.log(result);
});

// delete SEO (not data, only SEO)
database.deleteSEO(key_id, result => {
    console.log(result);
});

Combine Function

Search + Pagination

//  request argument :
//      select key (object) = pilih key yang value nya ingin di cari
//      show = berapa data yang ingin ditampilkan
//      page = sekarang dihalaman berapa
//      button_page = jumlah alinyemen button

// for test
const keyword = "and or on for in is woman";

console.log(database.searchWithPagination({
    description: keyword,
    title: keyword,
    category: keyword,
}, show, page, button_page));



Support the project

Apakah kamu menyukai project ini? Please support saya dengan menekan subscribe di Youtube Channel saya...


Donation Please

Butuh ngopi gans, kasih lah untuk biaya pengembangan agar mudah membeli alat dan buat makan
Donate

You might also like...

Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!

Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!

PostGraphile Instant lightning-fast GraphQL API backed primarily by your PostgreSQL database. Highly customisable and extensible thanks to incredibly

Jan 4, 2023

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️

A reactive database framework Build powerful React and React Native apps that scale from hundreds to tens of thousands of records and remain fast ⚡️ W

Jan 5, 2023

Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.

Lovefield Lovefield is a relational database written in pure JavaScript. It provides SQL-like syntax and works cross-browser (currently supporting Chr

Jan 3, 2023

Realm is a mobile database: an alternative to SQLite & key-value stores

Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript versions of Realm. Currently we s

Jan 3, 2023

:rocket: One command to generate REST APIs for any MySql Database.

:rocket: One command to generate REST APIs for any MySql Database.

Xmysql : One command to generate REST APIs for any MySql database Why this ? Generating REST APIs for a MySql database which does not follow conventio

Dec 30, 2022

Realtime database backend based on Operational Transformation (OT)

Realtime database backend based on Operational Transformation (OT)

This README is for [email protected]. For [email protected], see the 1.x-beta branch. To upgrade, see the upgrade guide. ShareDB ShareDB is a realtime databa

Dec 29, 2022

A transparent, in-memory, streaming write-on-update JavaScript database for Small Web applications that persists to a JavaScript transaction log.

JavaScript Database (JSDB) A zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to

Nov 13, 2022

The JavaScript Database, for Node.js, nw.js, electron and the browser

The JavaScript Database, for Node.js, nw.js, electron and the browser

The JavaScript Database Embedded persistent or in memory database for Node.js, nw.js, Electron and browsers, 100% JavaScript, no binary dependency. AP

Jan 2, 2023

The ultimate solution for populating your MongoDB database.

The ultimate solution for populating your MongoDB database.

Mongo Seeding The ultimate solution for populating your MongoDB database 🚀 Define MongoDB documents in JSON, JavaScript or even TypeScript files. Use

Dec 29, 2022
Owner
Jefri Herdi Triyanto
kamu, hei kamu, iya kamu... makasih udah datang :V
Jefri Herdi Triyanto
🔥 Dreamy-db - A Powerful database for storing, accessing, and managing multiple database.

Dreamy-db About Dreamy-db - A Powerful database for storing, accessing, and managing multiple databases. A powerful node.js module that allows you to

Dreamy Developer 24 Dec 22, 2022
DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB database, such as: connecting to the database, executing scripts, calling functions, uploading variables, etc.

DolphinDB JavaScript API English | 中文 Overview DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB

DolphinDB 6 Dec 12, 2022
Bluzelle is a smart, in-memory data store. It can be used as a cache or as a database.

SwarmDB ABOUT SWARMDB Bluzelle brings together the sharing economy and token economy. Bluzelle enables people to rent out their computer storage space

Bluzelle 225 Dec 31, 2022
A Node.js library for retrieving data from a PostgreSQL database with an interesting query language included.

RefQL A Node.js library for retrieving data from a PostgreSQL database with an interesting query language included. Introduction RefQL is about retrie

Rafael Tureluren 7 Nov 2, 2022
A JSON Database that saves your Json data in a file and makes it easy for you to perform CRUD operations.

What is dbcopycat A JSON Database that saves your Json data in a file and makes it easy for you to perform CRUD operations. ⚡️ Abilities Creates the f

İsmail Can Karataş 13 Jan 8, 2023
A WebAssembly build of the Tesseract OCR engine for use in the browser and Node

tesseract-wasm A WebAssembly build of the Tesseract OCR engine for use in the browser and Node. tesseract-wasm can detect and recognize text in docume

Robert Knight 80 Dec 28, 2022
Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Azure Data Studio is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Microsoft 7k Dec 31, 2022
🔄 A realtime Database for JavaScript Applications

RxDB A realtime Database for JavaScript Applications RxDB (short for Reactive Database) is a NoSQL-database for JavaScript Applications like Websites,

Daniel Meyer 18.6k Dec 31, 2022
⚡️ lowdb is a small local JSON database powered by Lodash (supports Node, Electron and the browser)

Lowdb Small JSON database for Node, Electron and the browser. Powered by Lodash. ⚡ db.get('posts') .push({ id: 1, title: 'lowdb is awesome'}) .wri

null 18.9k Dec 30, 2022
:koala: - PouchDB is a pocket-sized database.

PouchDB – The Database that Syncs! PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the br

PouchDB 15.4k Dec 30, 2022