JSPM

  • Created
  • Published
  • Downloads 163
  • Score
    100M100P100Q62959F
  • License MIT

A very intuitive local database.

Package Exports

  • secure-db
  • secure-db/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (secure-db) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.