1.2.2 • Published 1 year ago

malachitedb v1.2.2

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
1 year ago

MalachiteDB

The Malachite json Database

npm.io npm.io npm.io

Update notes

  • Implement a .remove() feature,

Todo

  • Add more support for more data types.

Syntax

Initialization

Initialize your database with the constructor by defining the json file location as the first variable and the json file name as the second.Example

Reading

Using .read() with no arguments with simple return the whole files contents, using .read(<index>) will attempt to read the value of the index specified.Example

Writing

Using .write(<index>, <value>) when is doesn't previously exist will create it in the database, using .write(<index>, <value>) when it currently exists will append the value in the databaseExample

Removing

Using .remove(<index>) will remove the index specified from the database.Example

Example

const { Database } = require('malachite');
const exampleDatabase = new Database('/databases', 'users'); // initialises the database

// Database Variables
console.log(exampleDatabase.databaseName); // returns the database name
console.log(exampleDatabase.location); // returns the database location

// Basic writing and reading
exampleDatabase.write('username', 'Bill'); // writes bill to the database with username as the index
exampleDatabase.read('username'); // returns the value of user1 (bill)

// Appending existing things in the database
exampleDatabase.write('password', 'p@ssw0rd123'); // writes p@ssw0rd123 to the database with password as the index
exampleDatabase.write('password', 'P@SSW0RD123'); // appends the value of password to P@SSW0RD123

// Removing from the database
exampleDatabase.remove('password'); // removes the password from the database

exampleDatabase.read(); // returns all values and index's in the database
1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago