secure-db

3.2.1 • Public • Published

SecureDB

PACKAGE VERSION PACKAGE DOWNLOADS PACKAGE SIZE PACKAGE LICENSE


SecureDB - A very intuitive local database

SecureDB is a simple and powerful local database that helps Node.js developers by storing data in JSON or encrypted.

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Recommended Node.js 16.15 or higher, stable version.

Installation is done using the npm install command:

$ npm install secure-db
const { Database } = require('secure-db');
const db = new Database('my-database');

Example Usage

const db = require('secure-db');

// Saves data to the database
db.set('Felipe', { age: 30 }); // Felipe: { age: 30 }

// Pushing an element to an array
db.push('Felipe.books', 'Harry Potter'); // Felipe: { books: ['Harry Potter'] }

// Add in a number
db.sum('Felipe.age', 3); // Felipe: { age: 33 }

// Subtract a number
db.sub('Felipe.age', 2); // Felipe: { age: 31 }

// Returns saved data
db.get('Felipe'); // Felipe: { age: 31, books: ['Harry Potter'] }
db.get('Felipe.books'); // Felipe: { books: ['Harry Potter'] }

It is possible to create multiple databases:

/* example creating databases for a users list */
const { Database } = require('secure-db');
const user1 = new Database('users', 'user1');
const user2 = new Database('users', 'user2');
const user3 = new Database('users', 'user3');

user1.set({ name: 'Mark', age: 32 });
user3.set('name', 'Joana');

user1.get('name'); // 'Mark'
user2.get('name'); // undefined

user1.get('name'); // 'Mark'

Following the previous example, it is possible to know which databases exist:

/* example returning all databases that exist within the user list */
const { getDatabases } = require('secure-db');

getDatabases('users', (user_list) => {
    user_list // ['user1', 'user2', 'user3']
});

Table of contents


FAQ

See the FAQ and please add your own questions if you think they would help others.

Package Sidebar

Install

npm i secure-db

Weekly Downloads

53

Version

3.2.1

License

MIT

Unpacked Size

81.2 kB

Total Files

61

Last publish

Collaborators

  • ezequiaslopes