Comparing version 0.1.2 to 0.1.4
10
index.js
const fs = require('fs'); | ||
const event = require('./event.js'); | ||
const json = require('./json.js'); | ||
@@ -8,2 +9,4 @@ const ldb = {}; | ||
ldb.json = json; | ||
// criar uma pasta para armazenar os dados | ||
@@ -67,8 +70,11 @@ ldb.createDB = (path, name, callback)=>{ | ||
ldb.sendData = (path, db, file, content, callback)=>{ | ||
let beforeContent; | ||
fs.readFile(`${path}/${db}/${file}.ldb`, (err, data)=>{ | ||
if(err) throw err; | ||
let beforeContent = data; | ||
beforeContent = data; | ||
fs.writeFile(`${path}/${file}.ldb`, `${beforeContent} ${content}`, (err)=>{ | ||
fs.writeFile(`${path}/${db}/${file}.ldb`, beforeContent+content+'\n', (err)=>{ | ||
if(err) throw err; | ||
@@ -75,0 +81,0 @@ |
{ | ||
"name": "ldbjs", | ||
"version": "0.1.2", | ||
"version": "0.1.4", | ||
"description": "Create and manage local db files and data", | ||
"main": "./index.js", | ||
"keywords": ["backend", "frontend", "fullstack", "local", "electron", "db", "database", "data", "files"], | ||
"keywords": [ | ||
"backend", | ||
"frontend", | ||
"fullstack", | ||
"local", | ||
"electron", | ||
"db", | ||
"database", | ||
"data", | ||
"files", | ||
"json" | ||
], | ||
"author": "raisess-Danilo_Santana", | ||
"homepage": "https://github.com/Raisess/ldbjs", | ||
"preferGlobal": "true", | ||
@@ -9,0 +21,0 @@ "dependencies": { |
@@ -140,2 +140,30 @@ # ldb | ||
Events are a very simple way to create and manage DBs and DBfiles in your application, don't repeat code anymore. | ||
Events are a very simple way to create and manage DBs and DBfiles in your application, don't repeat code anymore. | ||
### Sendding and getting data in a json | ||
```javascript | ||
const ldb = require('ldbjs'); | ||
// createing a json dbfile | ||
ldb.json.createDBFile('.', 'myJSONDBName', 'myJSONFileName', ()=>{ | ||
// optional callback | ||
console.log('json dbfile created'); | ||
}); | ||
// sending the data | ||
let myJSObj = { | ||
name: "Jhon", | ||
age: 27 | ||
}; | ||
ldb.json.sendData('.', 'myJSONDBName', 'myJSONFileName', myJSObj); | ||
// getting the data | ||
ldb.json.getData('.', 'myJSONDBName', 'myJSONFileName', (data)=>{ | ||
document.getElementById('demo').innerHTML = data; | ||
}); | ||
``` | ||
While a data are getted a js obj are return, the api automatically convert the json to a js object for you. |
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
8618
6
94
1
168
3