Coder Social home page Coder Social logo

easy-json-database's Introduction

Easy Json Database

This database is used for the Scratch For Discord project.

Example

const Database = require("easy-json-database");
const db = new Database("./some-database.json", {
    snapshots: {
        enabled: true,
        interval: 24 * 60 * 60 * 1000,
        folder: './backups/'
    }
});

// Set data
db.set("Hello", "World");

// Get data
db.get("Hello"); // World

// Delete data
db.delete("Hello");

db.get("Hello"); // undefined
db.has("Hello"); // false

db.set("age", 10);
db.add("age", 1); // 11
db.subtract("age", 9); // 2

db.set("array", [ "apple" ]);
db.push("array", "orange"); // [ "apple", "orange" ]

// Clear data
db.clear();

// Get all the data
db.all();

easy-json-database's People

Contributors

androz2091 avatar mimexe avatar patrickmarshall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

easy-json-database's Issues

Cela fonctionne en sql ?

Bonjour Androz,

J'ai fais ceci :

const Database = require("easy-json-database");
const db = new Database("../../money.sql");

await db.add(message.author.id, 100);

var a = db.get(message.author.id); 

message.channel.send(`+100, money ${a}`)

Et cela fonctionne.
Ducoup est ce du json ?
Ou alors cela écrit bien ?

Ya t'il un risque que les données soient corrompues, car le JSON est réputé pour.

Is not a function: key.split is not a function

Im getting this error while im trying to run my project on my virtual machine:

TypeError: key.split is not a function
    at setNestedProperty (C:\Users\Sapol\Desktop\CliGame\node_modules\easy-json-database\index.js:4:28)
    at EasyJsonDB.set (C:\Users\Sapol\Desktop\CliGame\node_modules\easy-json-database\index.js:129:9)
    at C:\Users\Sapol\Desktop\CliGame\index.js:22:6
    at Layer.handle [as handle_request] (C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Users\Sapol\Desktop\CliGame\node_modules\express\lib\router\index.js:275:10)

You can see my code here: https://hastebin.com/yezopozehu.js

path et non folder

Bonjour,
en utilisent le module je me suis rendu compte que pour choisir la déstination des backups il fait faire
const db = new Database("./some-database.json", {
snapshots: {
enabled: true,
interval: 24 * 60 * 60 * 1000,
path: './backups/'
}
});

et non pas

const db = new Database("./some-database.json", {
snapshots: {
enabled: true,
interval: 24 * 60 * 60 * 1000,
folder: './backups/'
}
});

j'éspère que cela vous sera utile :)

image

file.delete() not functioning

const db = require('easy-json-database');
const file1 = new db('./linked.json');
file1.delete('pending.' + interaction.options.getString('code'));

After running this piece of code, the piece of data still exists.

path.join is not a function

TypeError: path.join is not a function
at EasyJsonDB.makeSnapshot (D:\Khanh\vscode\recommendations\node_modules\easy-json-database\index.js:87:31)
at Timeout._onTimeout (D:\Khanh\vscode\recommendations\node_modules\easy-json-database\index.js:60:22)

SUGGESTIONS

Aujouter db.gpush() pour add une data dans tout les objets

db.get("aa") // {lol:"haha"}

db.gpush({keske:"ayaa"}) // undefined

db.get("aa") // {lol:"haha", keske:""ayaa}

(keske:""ayaa ajouté à toutes les data présentes)

the db.get result is not a string

i basically wanted to make some sort of a discord bot which uses machine learning (it generates responses from prompts), when i try to send the result which should be a string it tells me that "you cant send an empty message", i can print the result using console.log though

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.