Dreamy-db - A Powerful database for storing, accessing, and managing multiple databases.
A powerful node.js module that allows you to interact with the databases very easily.
- Object-oriented
- Feature-rich
- Performant
- Configurable
- 100% Promise-based
- Speedy and efficient
- Persistent storage
- Adapters: By default, data is cached in memory. Optionally, install and utilize a "storage adapter".
- Namespaces: Namespaces isolate elements within the database to enable useful functionalities.
- Custom Serializers: Utilizes its own data serialization methods to ensure consistency across various storage backends.
- Third-Party Adapters: You can optionally utilize third-party storage adapters or build your own.
- Embeddable: Designed to be easily embeddable inside modules.
- Data Types: Handles all the JSON types including
Buffer
. - Error-Handling: Connection errors are transmitted through, from the adapter to the main instance; consequently, connection errors do not exit or kill the process.
By default, data is cached in memory. Optionally, install and utilize a "storage adapter".
- MongoDB
- MySQL
- PostgreSQL
- Redis
- SQLite.
Node.js 12.x or newer is required.
Install dreamy-db using yarn:
yarn add dreamy-db
Or npm:
yarn add dreamy-db
const { Dreamy } = require('dreamy-db');
// One of the following
const db = new Dreamy(); // for in-memory storage
const db = new Dreamy('redis://user:pass@localhost:6379');
const db = new Dreamy('mongodb://user:pass@localhost:27017/dbname');
const db = new Dreamy('sqlite://path/to/database.sqlite');
const db = new Dreamy('postgresql://user:pass@localhost:5432/dbname');
const db = new Dreamy('mysql://user:pass@localhost:3306/dbname');
db.on('error', error => console.error('Dreamy#Connection Error: ', error));
(async () => {
await db
.set('Profile', {
id: 1234567890,
Name: 'Dreamy',
verified: true,
tags: ['dreamy-db', 'database'],
height: 6.2,
Balance: 450,
Job: null,
})
.then(console.log)
.catch(console.error);
// Returns an array that contains the keys of each element.
await db
.keys()
.then(data => console.log(data))
.catch(console.error);
// Returns an array that contains the values of each element.
await db
.values()
.then(data => console.log(data))
.catch(console.error);
// Gets all the elements from the database.
await db
.all()
.then(data => console.log(data))
.catch(console.error);
// Clears all elements from the database.
await db.clear().then(console.log).catch(console.error);
// Deletes an element from the database by key.
await db.delete('profile').then(console.log).catch(console.error);
})(); // Callback