3.0.0 • Published 26 days ago

qd.db v3.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
26 days ago

Installation

Use npm or yarn to install qd.db package :

npm install qd.db
yarn add qd.db

Initialization

Javascript Example

const { QuantumDB } = require('qd.db');
const db = new QuantumDB('database.json');//Specify a file to be the database

Typescript Example

import { QuantumDB } from 'qd.db'
const db = new QuantumDB('database.json');//Specify a file to be the database

Quick Start

Considering that you used the previous code to initialize the database :

async function example() {
  // Adding a value
  await db.set('A', 'Apple');
  const value = await db.get('A');
  console.log(value);// Output < Apple >

  // Adding a value in an array
  await db.push('B', 'Banana');
  await db.push('B', 'Blueberry');
  const array = await db.get('B');
  console.log(array);// Output < ['Banana', 'Blueberry'] >

  // Removing a value from an array
  await db.pull('B', 'Banana');
  const nextArray = await db.get('B');
  console.log(nextArray);// Output < ['Blueberry'] >

  // Deleting a value
  await db.delete('A');

  // Getting all data
  const data = await db.getAll();
  console.log(data);// Output < [ { key: 'B', value: ['Blueberry'] } ] >

  // Clearing all data
  await db.clearAll();
}

example();

Api Reference

  • set('key', 'value') : Sets a value for a specified key.
  • push('key', 'value') : Pushs a value in an array for a specified key.
  • pull('key', 'value') : Pulls a value from an array for a specified key.
  • get('key') : Returns a value using the key.
  • delete('key') : Deletes an item using the key.
  • getAll() : Returns all database data.
  • clearAll() : Clears all database data.

Our Community

To inquire about the package and get help with every part of it, you can visit our server on Discord.

2.5.0

26 days ago

3.0.0

26 days ago

2.0.0

28 days ago

1.0.0-quantum

1 month ago

1.0.2

1 month ago

0.0.1

1 month ago

1.0.0

1 month ago