TrashDB
Small in memory database used for easy data managment without the need of complex setup. The database is based on the JavaScript Map
class.
Installation
You could use Yarn or NPM to install it
// Yarnyard add trashdb // NPMnpm install --save trashdb
Quick Start
// Normall require const TrashDb = // ES6 Imports const db = ; // Create collection/namespace to hold the data const users = db // Insert data into collectionusers // Get last inserted idjohnId = users; // Bulk insertusers userssize// => 3 // Get data from collection const john = users; // => { // id: 'xxxxx', // data: { firstname: 'John', email: 'john@email.com' }, // metadata: { // created_at: <timestamp>, // updated_at: <timestamp> // } // } // Update data from collection johndatafirstname = 'Mike'; // Check to see if some ID existif users // John exist const result = users if result === false // The record is not updated or not existing else // Updated record // List of all ids into the collectionusersindexes // Convert Map to Arrayusers// => Array of users // Remove datausers // Remove all datausers // Use pagingconst paging = users // => {// page: 1,// pages: 4,// limit: 15,// total: 60,// records: [ <UserRecords> ... ]// }