Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
'use strict';
const Database = require('../src/Database');
//let database = new Database(__dirname + '/example.db'); // Use file "example.db"
let database = new Database(null); // Use memory
database.define('user', {
id: {type: Number, index: true},
name: String,
// Insert into table "user" with values id & name
database.insert('user', {id: 1, name: 'Bob'});
database.insert('user', {id: 2, name: 'Henk'});
database.insert('user', {id: 3, name: 'Bob'});
// Get the first result for the table 'user' where the column `id` equals to 1
database.get('user', {id: 1}, user => {
console.log(`User 1 has the name: ${}`);
// Find all results in table 'user' where the column `name` equals to 'Bob'
database.find('user', {name: 'Bob'}, users => {
console.log(`Amount of Bob's: ${users.length}`);
// Remove all all entries in the table 'user' where the column 'id' equals to 1
database.remove('user', {id: 1});

This comment has been minimized.

Copy link
Owner Author

@nielsvanvelzen nielsvanvelzen commented Nov 5, 2016

Benchmark results:

insert-10k: 41.122ms
find-no-index: 3.519ms
find-index: 0.200ms
remove: 5434.659ms

the remove function is pretty slow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.