JSON-Base – database software completely built as JSON files

栏目: IT技术 · 发布时间: 5年前

内容简介:A database software completely built as JSON files in backend. A powerful, portable and simple database works on top of JSON files. It is like a database software, currently having basic CRUD operation features. You can use this as a backend for your ReST

Json-Base

A database software completely built as JSON files in backend. A powerful, portable and simple database works on top of JSON files. It is like a database software, currently having basic CRUD operation features. You can use this as a backend for your ReST APIs as well. The software is completely free and opensource. We are coming up with new features and providing more updates. The another beautiful advantage with JSON-base is since it is a NPM module, this fits well in your nodeJs applications eco system. if you want to develop quick prototypes/poc or need of a database with minimal requirements then, JSONBASe is an must option that you can consider. However there is a limitation if you go beyond a million records per table.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. Checckout the below examples to know how to use the JSON-Base built in APIs.

Installing

A step by step series of examples that tell you how to get started with JSON-Base

npm i @syamdanda/json-base

And then import the json-base npm module into your nodejs application

var jsonDB = require('@syamdanda/json-base');

Check-out the below code snippets to use the JSON-Base module in your application.

Database Operations

  • To create database
let options = {
  'name': 'myDatabase'
};
jsonDB.createDatabase(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To delete database
let options = {
  'name': 'myDatabase'
};
jsonDB.dropDatabase(options, function(response) {
	console.log(JSON.stringify(response));
});
  • Table Operations

    • To create table
let options = {
  'database': 'myDatabase',
  'tableName': 'Users'
};

jsonDB.createTable(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To drop table
let options = {
  'database': 'myDatabase',
  'tableName': 'Users'
};

jsonDB.dropTable(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To insert record table
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'record': {'email': 'name@domain.com', 'phone': '+1 1234567890', 'name': 'userName'}
};

jsonDB.insertRecord(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To insert more than one record
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'records': [{'email': 'name@domain.com', 'phone': '+1 1234567890', 'name': 'userName'},{'email': 'name2@domain.com', 'phone': '+1 1234567890', 'name': 'userName2'}]
};

jsonDB.insertRecord(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To get record by Id
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'recordId': 1
};

jsonDB.getRecordById(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To get record by key value

If you want to search and rer=trieve a record based on some key and value use the below method.

let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'key': 'email', 
   'value': 'abc@domain.com'
};

jsonDB.getRecordByKeyValue(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To get record by more than one key value or object.

If you want to search and rertrieve a record based on more than one key and value use the below method.

let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'obj': {'email': 'name@domain.com', 'phone': '+1 1234567890', 'name': 'userName'}
};

jsonDB.getRecordByObject(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To get records based on search flag you can define any one value for flag
    • beginsWith : searches records whose value is begins with the mentioned value for the key
    • endsWith : searches records whose value is endsWith with the mentioned value for the key
    • contains : searches records whose value contains with the mentioned value for the key
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
  'key': 'email',
  'value': 'gmail',
  'flag': 'contains'
};

jsonDB.getRecordsBySearch(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To get all records from a table
let options = {
  'database': 'myDatabase',
  'tableName': 'Users'
};

jsonDB.getAllRecords(options, function(response) {
  console.log(JSON.stringify(response));
});
  • To delete record by Id
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'recordId': 1
};

jsonDB.deleteRecordById(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To update record by Id
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'recordId': 1,
   'recordObj': {'email': 'new123', 'pwd': 'password'}
};

jsonDB.updateRecordById(options, function(response) {
	console.log(JSON.stringify(response));
});
  • To update record by key value
let options = {
  'database': 'myDatabase',
  'tableName': 'Users',
   'key': 'email',
   'value': 'mymail@domain.com',
   'recordObj': {'email': 'new123', 'pwd': 'password'}
};

jsonDB.updateRecordByKeyValue(options, function(response) {
  console.log(JSON.stringify(response));
});

Contributing

Please readfor details on our code of conduct, and the process for submitting pull requests to us.

Versioning

  • Issue fixes in 0.1.0 on 01.Jul.2020
  • Added getRecordsBySearch API in 0.0.9 on 01.Jul.2020
  • Documentation and issue fixes in 0.0.8 on 30.Jun.2020
  • Added documentation in 0.0.7 on 29.Jun.2020
  • Current stable version is 0.0.5 which is released on 27.Jun.2020

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

原则

原则

[美] 瑞·达利欧 / 刘波、綦相 / 中信出版社 / 2018-1 / CNY 98.00

※ 华尔街投资大神、对冲基金公司桥水创始人,人生经验之作 作者瑞·达利欧出身美国普通中产家庭,26岁时被炒鱿鱼后在自己的两居室内创办了桥水,现在桥水管理资金超过1 500亿美元,截至2015年年底,盈利超过450亿美元。达利欧曾成功预测2008年金融危机,现在将其白手起 家以来40多年的生活和工作原则公开。 ※ 多角度、立体阐述生活、工作、管理原则 包含21条高原则、139条中原......一起来看看 《原则》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换