🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

opennodedb

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opennodedb

An open source hash table and binary search db using node.js.

1.0.0
latest
npm
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

About

OpenNodeDB is an open source database implementation made by me (Matthew Snow). It's just a simple solution that uses an ORM approach to storing JSON data both in memory and in files (file system still in the works). Although the index system created doesn't use B or B+ trees, it uses a hash table for indexes (only for the id field), and each collection of record sets that the index points to has an incrementing id, we use a binary search method to quickly locate a record when searched by id.

Description

This database implementation will be best used for small/medium sized intranets, or apps, where performance is a must. More to come as this project starts to take shape.

How to Use

From a terminal, inside main project

npm install opennodedb

From inside a node.js project

// create new database instance
var OpenNodeDB = require('opennodedb');
var db = new OpenNodeDB();


// create a model w/ validators, getters and setters
db.createModel('Users', 1, { name: String, password: String },
	{
		validators: {
			name: function (name) {
				if (name.length < 5) throw new Error('Name of length needs to be at least 5 characters!')
			}
		},

		getters: {
			name: function (name) {
				return name + 'dbcombine!'
			}
		},

		setters: {
			name: function (name) {
				return name + ' I got appended to the name haha!.'
			}
		}
	})



// inserting an object: db.insert(modelname, object)
db.insert('Users', { name: 'Apple Pear', password: 'doublefruit123'})
.then(user => {
	// here you can see that apple pear will be assigned the id of 0
	// each subsequent id will be incremented
})
.catch(err => {
	//....
})


// finding a user or users: db.read(modelname, queryParamsObj)
db.read('Users', { name: 'Apple Pear'})
.then(foundData => {
	// foundData will be an array with our results
	// if an id was searched, there will only be 1 result at foundData[0]
})

Test Results

Test TypeTimes
Inserting 100,000 items198.723 ms
Reading by id (after 100000)0.075 ms
Reading by name ""3.9 ms

Goals

  • Implement Getters functionality
  • Create a file persistence mechanism using child processes.
  • Creating multiple driver mechanisms (using a tcp socket) with auth.
  • Create update functionality
  • Create delete functionality

FAQs

Package last updated on 17 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts