1.2.0 • Published 4 years ago

zanci.db v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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: true, key2: "true"}
  • 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 /.

Found an issue? Post it in github!

1.2.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago