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 0.1.2 to 0.1.4

json.js

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 @@

16

package.json
{
"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.
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