Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldbjs

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldbjs - npm Package Compare versions

Comparing version 1.1.0 to 1.3.0

21

index.js

@@ -15,3 +15,3 @@ const fs = require('fs');

// get the project dir path
// get the ldb dir path
ldb.dir = __dirname;

@@ -114,3 +114,22 @@

}
// backup of file data
ldb.backup = (path, db, file, callback)=>{
s.writeFile(`${path}/${db}/${file}.backup.ldb`, '', (err)=>{
if(err) throw err;
fs.copyFile(`${path}/${db}/${file}.ldb`, `${path}/${db}/${file}.backup.ldb`, (err)=>{
if(err) throw err;
if(callback) callback();
});
}
}
// rollback backup to file
ldb.rollback = (path, db, file, callback)=>{
fs.copyFile(`${path}/${db}/${file}.backup.ldb`, `${path}/${db}/${file}.ldb`, (err)=>{
if(err) throw err;
if(callback) callback();
});
}
module.exports = ldb;

@@ -14,3 +14,3 @@ // json module

}
// parse a JS obj to JSON string notation and send
json.sendData = (path, db, file, jsObj, callback)=>{

@@ -23,3 +23,3 @@ fs.writeFile(`${path}/${db}/${file}.json`, JSON.stringify(jsObj), (err)=>{

}
// parse a JSON to JS obj and get data
json.getData = (path, db, file, callback)=>{

@@ -32,3 +32,22 @@ fs.readFile(`${path}/${db}/${file}.json`, (err, data)=>{

}
// backup of file data
json.backup = (path, db, file, callback)=>{
fs.writeFile(`${path}/${db}/${file}.backup.json`, '', (err)=>{
if(err) throw err;
fs.copyFile(`${path}/${db}/${file}.json`, `${path}/${db}/${file}.backup.json`, (err)=>{
if(err) throw err;
if(callback) callback();
});
}
}
// rollback backup to file
json.rollback = (path, db, file, callback)=>{
fs.copyFile(`${path}/${db}/${file}.backup.json`, `${path}/${db}/${file}.json`, (err)=>{
if(err) throw err;
if(callback) callback();
});
}
module.exports = json;

2

package.json
{
"name": "ldbjs",
"version": "1.1.0",
"version": "1.3.0",
"description": "Create and manage local db files and data",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -206,2 +206,18 @@ # ldbjs

### Backup and rollback
```javascript
const ldb = require('ldbjs');
ldb.backup('.', 'dbName', 'fileName');
// create a fileName.backup.ldb file
ldb.roolback('.', 'dbName', 'fileName');
// get the fileName.backup.ldb data and put in fileName.ldb
// To use in json is very similar, put the json module
ldb.json.backup('.', 'dbName', 'fileName');
// use the same logic
```
#### To report bugs or open a inssue in [github repo](https://github.com/raisses/ldbjs) or send a email to **danilosantana456789@gmail.com** no spam pls.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc