Git Product home page Git Product logo

zanci.db's Introduction

Zanci.DB

  • Simple json database. Backup system included!

How to start?

  • Install the project first by using:
npm i zanci.db
  • Don't forget to define it!
const { Database } = require('zanci.db')
const db = new Database("MySuperSecretDatabase.json")
  • Typescript support added as well!
import { Database } from 'zanci.db';
const db = new Database();

Good to know

  • Now if a file doesn't exist, it will automatically create it!
  • Path is automatically set to "./"

Examples

  • Define an object and push it to the file.
let object1 = {key: true, key2: "true"}
db.set('Object', object1); // Object: {key: "value1", key2: "value2"}
  • Define an array and push it to the file.
let array1 = ['element', 'element2']
db.set('Array', array1); // Array: ['element', 'element2']
db.push('Array', 'element3'); // Array: ['element', 'element2', 'element3']
  • Fetch an object / array.
db.objectFetch('Object', 'key'); // key: "value1"
db.arrayFetch('Array', 1); // element2
  • Fetch data in the file.
db.fetch('data'); // Fetches the value of the data
db.get('data'); // Get the value of the data
db.fetchAll(); // Fetches all the data in the database
db.all(); // Fetches everything in the database
  • Remove data in the file.
db.remove('data'); // Removes the data from the database
db.delete('Array', 'element3'); // Removing something from an array using value
db.deleteKey('object', 'key'); // Deletes the provided key from the given object
db.deleteEach('data'); // Deletes each data that starts with the given parameter
  • Remove database content. Carefully with this!
db.clear(); // Clears everything from the database
db.destroy(); // Deletes the database file
  • Boolean functions.
db.has('data'); // Returns "true" or "false" if the database has the data or not.
  • Math functions.
db.add('data', 1); // Adds one to the data
db.subtract('data', 1); // Subtracts one from the data
db.math("eco", "+", 10); // Adds 10 to the data. You can use +, -, * and /.

zanci.db's People

Contributors

zanci19 avatar

Watchers

 avatar

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.