Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abmsourav/localdb
LocalDB is CRUD module for NodeJS using FileSystem
https://github.com/abmsourav/localdb
crud-api node-module nodejs npm npm-module npm-package
Last synced: 18 days ago
JSON representation
LocalDB is CRUD module for NodeJS using FileSystem
- Host: GitHub
- URL: https://github.com/abmsourav/localdb
- Owner: AbmSourav
- License: mit
- Created: 2021-01-08T10:18:23.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-25T09:18:17.000Z (about 3 years ago)
- Last Synced: 2024-10-03T09:41:51.494Z (about 1 month ago)
- Topics: crud-api, node-module, nodejs, npm, npm-module, npm-package
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@abmsourav/localdb
- Size: 30.3 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LocalDB
LocalDB is a NodeJS CRUD API.
It uses local file system for CRUD operation. It's a promise based API.
## Installation
`npm i @abmsourav/localdb`
## API
**GET** `localDB.get()`
**POST** `localDB.set(jsonObject)`
**INSERT** `localDB.insert(jsonObject, jsonObject)`
**UPDATE** `localDB.update(jsonObject, jsonObject)`
**DELETE** `localDB.remove(jsonObject)`
**SEARCH** `localDB.search(string, string, bool)`
**SEARCH** `localDB.searchByValue(string, bool)`
## Initialization
create a json file on your project root and initialize like below.
Please note: It must be a json file.
```js
const ldb = localDB('./db.json');
```
## API Uses
```js
const {localDB} = require('@abmsourav/localdb');
const ldb = localDB('./db.json');const data = {names: "Sourav", email: "[email protected]"};
// add new data
ldb.set(data)
.catch( (err) => console.log(err) );// Insert data on and existing object
ldb.insert({"id": "1247flsf"}, {"Full Name": "Keramot UL Islam"}) // 1. find the object, 2. add property and value
.catch( (err) => console.log(err) );// get data from localDB
ldb.get()
.then( (data) => console.log(data) ) // [ {name: 'Sourav', email: '[email protected]'} ]
.catch( (err) => console.log(err) );// update data
ldb.update({"id": "abm"}, {name: "AbmSourav"}) // args: 1.where update'll made, 2.new data
.catch( err => console.log(err) );// Delete data
ldb.remove({name: "Abm Sourav"})
.catch( err => console.log(err) );// Search unique data
ldb.search("id", "123454ls") // key and value
.then( data => console.log(data) );// search all matches data
ldb.search("name", "Sourav", false) // key, value and unique
.then( data => console.log(data) );// Search all data that matches this value
ldb.searchByValue("Abm Sourav")
.then( data => console.log(data) );// Search unique data that matches the value
ldb.searchByValue("Abm Sourav", true)
.then( data => console.log(data) );```
.