Comparing version 1.7.0 to 1.8.0
16
json.js
@@ -42,2 +42,18 @@ // json module | ||
} | ||
json.delete = (path, db, file, args, index, callback)=>{ | ||
fs.readFile(`${path}/${db}/${file}.json`, (err, data)=>{ | ||
if(err) throw err; | ||
let json = JSON.parse(data); | ||
if(args === '' || args === null || args === undefined) delete json[index];; | ||
if(args !== '' && args !== null && args !== undefined) delete json[args][index];; | ||
fs.writeFile(`${path}/${db}/${file}.json`, JSON.stringify(json), (err)=>{ | ||
if(err) throw err; | ||
if(callback) callback(); | ||
}); | ||
}); | ||
} | ||
// push data to json field array | ||
@@ -44,0 +60,0 @@ json.push = (path, db, file, args, index, push, callback)=>{ |
{ | ||
"name": "ldbjs", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Create and manage local db files and data", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
# ldbjs | ||
A lib to create and manage local db files and data, whit a simple send and get system, | ||
save any data, html content, js objects and arrays, json, some texts, anything. | ||
save any data, html content, js objects and arrays, JSON, some texts, anything. | ||
@@ -192,3 +192,3 @@ | ||
### JSON insert | ||
### JSON insert and delete | ||
@@ -217,2 +217,8 @@ ```javascript | ||
ldb.json.insert('.', 'myJSONDBName', 'myJSONFileName', 'parents', 'bro', 'Daniel'); | ||
// to create new property | ||
ldb.json.insert('.', 'myJSONDBName', 'myJSONFileName', null, 'lastName', 'Drake'); | ||
// to delete a property | ||
ldb.json.delete('.', 'myJSONDBName', 'myJSONFileName', null, 'parents'); | ||
``` | ||
@@ -219,0 +225,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16500
238
286