Skip to content

nitlix/Lixbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lixbase @2.0.0 Node.JS [MIT License]

Banner

A manual sharded and managed NoSQL object-focused database made for the cool kids.

Built with πŸ’› by Nitlix

  • Nitlix - The creator of this project

Installation

Using NPM:

$ npm i lixbase --save

or

$ npm install lixbase --save

Features

More added soon.

Quickstart showcase

πŸ₯³ showcase.js

Here is our initial starting file, where we use Lixbase to manage our database files.

import Lixbase from "lixbase"


async function main() {
    let client = new Lixbase.Client


    //Custom object - Account
    client.objects.account = {
        id: null,
        type: null,
        data: null,
        created: null
    }

    //Custom object - Session
    client.objects.session = {
        id: null,
        type: null,
        data: null
    }

    //Custom saving directory
    client.dir = 'custom_dir_name'

    //Custom Dynamic ID Generation
    client.format.id = '[SHARD]-[TIME]-[RANDOM]'

    //No autosave
    client.autosave = -1

    //Autosaving every 10 seconds
    client.autosave = 10


    
    //Initialise our client after the configuration
    await client.init("shard_name")

    //Create new account object in the database
    client.addObject('account', {data: 'test', created: Date.now()}) 

    //Create new session object in the database
    client.addObject('session', {data: 'test2'}, 5)

    //Create another session object in the database, just for show
    client.addObject('session', {data: 'test3'}, 5)

    //Brand new query function, like SQL, but on steroids.
    //Returns a dict with objects that match the query function.
    //(Which is matching the data key 'data' to the string 'test')
    //Check out the output!
    console.log(
        client.query(['*'], (data)=>{
            if (data.data == 'test') {
                return true
            }
            return false
        }, ['data', 'created'])
    ) 


    //Save the database file
    client.save()



    // After all of this
    // check out /custom_dir_name/shard_name.json!
    // Good luck developing!
}


main()

βœ… The output JSON

The file used to store and manage our database's object located at (custom_dir_name/shard_name.json).

😎 Documentation

Lixbase is assumed to be imported as "Lixbase" using

import Lixbase from "lixbase"

Client

Initialise using:

let client = new Lixbase.Client

Client Properties


Data

client.data
// The raw JSON data of your database.
// Can be edited:
client.data.id['hello'] = 'world'

Shard

client.shard
// The shard of your database
// Initially set with:
client.init("Shard goes here")

Autosave

client.autosave
// The period of autosave in your database (in seconds)
// At init(), if it is lower than 0:
// then autosaving won't happen.

// Change it before init()

Object types

client.objects
// The storage for all batch object types of your database.
// Stored in a dict.
// Create a new object structure using:

client.objects.account = {
    id: null,
    type: null,
    name: null,
    data: null
}

// WARNING!
// Each object type registry must have an 'id' and 'type'.

Directory

client.dir
// The directory where the database filed will be saved in.
// Change the variable before init()

Database Orientation

client.databaseOrientation
// When creating a database file 
// Lixbase will use this default structure.
// Do not edit out the existing modules unless
// you are planning to build a custom
// database using Lixbase.

// Use before init()

// Example usage:
client.databaseOrientation = {
    'id': {},
    'batch': {},
    'pets': {
        'cats': [],
        'dogs': []
    }
}

Formats

client.format.id
// The format for dynamically generating IDs on the go.
// The variables are:
// [SHARD], [TIME], [RANDOM], [NEXT]

// Example:
client.format.id = '[SHARD]-[TIME]-[RANDOM]'



// The [NEXT] Variable must go at the end
// it handles the going up of IDs in order.
// For example: 
client.shard = 'N1'
client.format.id = '[SHARD]-[NEXT]'

//The first object will have an ID of:
'N1-0'
//The next one will be:
'N1-1'
//And so on. 

Backups

client.backups.enabled
// Bool
// Used at init() to trigger the backups thread.

client.backups.interval
// Integer interval in MINUTES.

client.backups.dir
// Custom directory name for backups

client.backups.format
// The format for backup file saves
// The variables are:
// [SHARD], [TIME], [RANDOM]
// Example:
client.backups.format = '[SHARD]-[TIME]'

βš’οΈ Functions

.init()

await client.init(shard)

// Initialises the database using the provided shard.
// Default shard name: "N1"
// Creates any new files needed
// Starts out any background processes
// like autosave and backups.

// Use await for client.init(shard) to wait for it to finish.

This library is still being developed. It may have some bugs!

More docs coming later!

About

A lightweight sharded manual managed NoSQL database πŸ“¦ built on Node.js for the cool kids. (Abandoned)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors