Introduction - Not a Real DB

It's a "fake" database NPM package that works as a database that allows you to store a data in JSON file. Install NPM package using below command.
  1. npm i notarealdb || yarn add notarealdb
Official Package Link.
Benefits of notarealdb Package

How To Use It


Create a Datastore instance, where you want to store data, and then create an object of each collection of JSON file.

For example, let's create JSON files for students and courses so that you need to create files on ./data/students.json and ./data/courses.json files. Once files are saved you need to integrate into applications as below
  1. // Referenced 'notarealdb' package
  2. const { DataStore } = require('notarealdb');
  3. // Referenced JSON files or database files
  4. const store = new DataStore('./data');
  5. const students = store.collection('students');
  6. const courses = store.collection('course');
Performing CRUD operation using notarealdb package
  1. // Create new item will return auto generated ID in return
  2. const id = courses.create({ coursename : 'NodeJs', createdDate : new Date().toLocaleString() }); // => 'XW449uPiN
  3. // Fetch list of all records from collection
  4. courses.list(); // => [{id: 'XW449uPiN', coursename : 'NodeJs', createdDate : "10/2/2021, 12:35:59 pm" }]
  5. // get single record from json file based on ID
  6. courses.get('XW449uPiN'); // => {id: 'XW449uPiN', coursename : 'NodeJs', createdDate : "10/2/2021, 12:35:59 pm"}
  7. // update record from json file
  8. courses.update({id: 'XW449uPiN', coursename : 'NodeJs Update', createdDate : new Date().toLocaleString()});
  9. // delete record from json file
  10. courses.delete('XW449uPiN');

Summary

This is a free NPM package which allows you to perform simple CRUD operations with a database of JSON file. Sometimes we face many issues whenever we deal with the client for a demo of applications. We cannot purchase any proper database environment for simple applications due to the cost of databases nowadays, so to reduce those issue this package allows you to develop simple CRUD based applications that we can show as an example. It's very very easy to integrate and utilize.