secure-db
v3.2.1
Published
A very intuitive local database.
Downloads
102
Maintainers
Readme
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.
- Fast and high performance 🚀
- Encryption using security key 🔒
- Infinite separate databases 💯
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
- Get Started;
- Basic code;
- (Saving) and (Getting) data;
- Managing arrays;
- Resetting the database;
- Deleting individual data;
- Create multiple databases;
- Database sections;
- Getting the list of existing databases;
- Deleting the database completely;
- Manage data security;
- Enabling encryption on the database;
- Setting the environment variables and the Security Key;
- Changing encryption mode;
- Changing the output;
- Setting different keys for each database;
FAQ
See the FAQ and please add your own questions if you think they would help others.