DEV Community

Cover image for Full-blown Database Management Software written completely in Javascirpt ✨
Keerthi Vasan
Keerthi Vasan

Posted on

11 5

Full-blown Database Management Software written completely in Javascirpt ✨

This is not just a fancy client, it's a complete DBMS which is completely written in NodeJS with type declarations and documentation to ease developer's introduction to the amazing world of SavanahDB

It is a NoSQL meaning you can store data flexibly in the JSON format but it can also be used to establish deep relations between tables, have groups in the filter, join data from different tables!

Let's create a Social Network with this Database :

First, let's start a server to receive and process requests via various clients

import { Server } from 'savanahdb' 

let server = new Server({
  path: '/var/db/', 
  masterKey: 'ksKkharaudjwnwbduxnsn5yahahhwwsmma' // 64-bit key to encrypt important configurations
}) 
Enter fullscreen mode Exit fullscreen mode

And that's it! Run it with pm2
You have your own server running now!

We connect to it using a client :

import { Client } from 'savanahdb';

let client = new Client({
   user : "randomusr",
   pass : "fdASDFajd9awjef98awjefioawjeasdf"
})

let db = client.db('network')
let users = db.table('users')
let posts = db.table('posts')  
Enter fullscreen mode Exit fullscreen mode

First, you store the User Document when they sign up:

users.insert({
    name : 'John Adam',
    city : 'New York',
    tier : 'Silver',
    prem : true,
    id : 'usrOw9a0eif0923aewf'
})
Enter fullscreen mode Exit fullscreen mode

Next you store two Posts they posted with reference to their id essentially establishing a relationship between the tables:

posts.insert({
    usr : 'usrOw9a0eif0923aewf',
    content : 'I love this network.'
})
// A Few Moments Later..
posts.insert({
    usr : 'usrOw9a0eif0923aewf',
    content : "Nvm, I don't know anymore"
})
Enter fullscreen mode Exit fullscreen mode

Now when someone visits the Orginal User's Profile to list the posts they have posted, you create a search like this :

let usr = await users.search('id == "usrOw9a0eif0923aewf"', {
    join : {
      posts : 'that.usr == this.id' 
    }
}
Enter fullscreen mode Exit fullscreen mode

In this case the usr Document will be :

[{
   name : 'John Adam',
    city : 'New York',
    tier : 'Silver',
    prem : true,
    id : 'usrOw9a0eif0923aewf',
    posts : [{
    usr : 'usrOw9a0eif0923aewf',
    content : 'I love this network.'
  },{
    usr : 'usrOw9a0eif0923aewf',
    content : "Nvm, I don't know anymore"
  }]
}] 
Enter fullscreen mode Exit fullscreen mode

Extremely capable Software do check it out!!

It is available to check out for free here : https://www.npmjs.com/package/savanahdb

If you are interested in the development or would like to receive updates for the package, you can join the official Discord Server here : https://www.discord.com/invite/GBmMQd2xtB

API Trace View

Struggling with slow API calls? 👀

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (8)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
nectres profile image
Keerthi Vasan

I will be updating the README of the npm package with benchmarks quite soon.

Collapse
 
nectres profile image
Keerthi Vasan

I have already benchmarked it against Mongodb what else should I add to the comparison?

Collapse
 
harshvats2000 profile image
HARSH VATS

Your npm link is broken!

Collapse
 
nectres profile image
Keerthi Vasan

Sorry! Fixed now. Thanks for pointing out

Collapse
 
fullrx profile image
Dmitry Maltsev • Edited

What about BigData support?

Collapse
 
nectres profile image
Keerthi Vasan • Edited

Yes. With sharding and the concept of connecting multiple servers as a hive it should be able to process terabytes of data, be highly available and fast

I am working on a gitbook documentation to explain advanced concepts like sharding, hive, scaling and security with SavanahDB whenever it's ready it will linked in the readme. Future versions will be able to scale diagonally ( horizontally and vertically) on demand

Collapse
 
crimsonmed profile image
Médéric Burlet

The syntax reminds me of prisma.
Keep up the good work!

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay