savanahdb
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Introduction to Savanah

Edition Release Version Activity

Savanah Saber Edition

SavanahDB

A Full-blown Professional Database Management Software written completely in Javascript

Support and Contribution

To request new features, keep up with the updates and get support, Join the Official Discord Server : Invite

This package is developed, maintained and updated with a single person. If you would like to financially support the creator and thereby this package consider becoming a patron : Patreon

Basic Documentation

Setting up a Server

Write the below code in a file

server.js

import { Server } from 'savanahdb'

let server = new Server({
    path : "/var/data/",
    masterKey : process.env.MASTER_KEY   
})

By default it listens in http://localhost:7777 but it can be changed by passing host,port in the Server options

Run it with pm2

Connecting to the Server

import { Client } from 'savanahdb'

let client = new Client({
    user : "root",
    pass : "create a new admin account with a secure password and delete this"   
})

let db = client.db("demo")

let tb = db.table("no")

The above credentials are the Default ones, please do remember to create a new user and delete the root user

Insert

Inserting data into a table is easy, structure the data into JSON Format and pass it to insert() function of a Table

tb.insert({
   author : "Robert",
   price : 120,
   premium : true
})

or to insert a set of documents :

tb.insertSet([{
   author : "Robert",
   price : 120,
   premium : true
},{
   author : "John",
   price : 40,
   premium : false
}])

Search

Valid Operators : !=, ==, ===, >, <, >=, <=

Get an array of documents that match a given condition

tb.search('name == "John"') // gets all documents with name as John

tb.search('( name == "John" && price > 100 ) || premium === true') 
// you can group conditions to get better suited results

tb.search('name != "John"' , {
  join : {
       authors : 'that.name == this.author as author_info'
  },
  limit : 5
})
//joins documents from other tables. Here "authors" is the table from 
// which the data is going to be joined
// and limits the result to a maximum of 5 Documents

Update

Update existing data with a condition and limit

tb.update('author == "John"' , {
  premium : false,
  _inc : ['rep', 'price'] // increment properties
} , { limit : 2 })

Limits defaults to 1, pass "none" as limit to update all records that satisfy the condition

Delete

tb.delete('premium === false')

Limits defaults to 1, pass "none" as limit to delete all records that satisfy the condition

Guides and documentation covering more advanced concepts like sharding, etc.. are in https://www.gitbook.com/

Copyright (c) 2021 Keerthi Vasan mrsheepwithglasses@gmail.com

Patreon : here

Discord Server : Invite

License

Click here to read the License

Package Sidebar

Install

npm i savanahdb

Weekly Downloads

1

Version

1.0.3

License

SEE LICENSE IN LICENSE.md

Unpacked Size

71.2 kB

Total Files

22

Last publish

Collaborators

  • keerthiv23