Git Product home page Git Product logo

learndb's Introduction

LuisDB

My study on how to create a database

Hello, this is the repository for my database project, I am trying to learn how to create a database from scratch using Node.js

My objective is to understand a little better how databases work internally

Installation

You need to have Node.js and NPM to install and use this project

npm i learndb

Usage

you can use this in two ways, either as an REPL or as a driver for the database

REPL

If you want to use this project as a REPL I would adivise to clone it instead of installing it, if you have it cloned, to access the REPL, all you need to do is type this on the terminal:

node index.js repl

REPL Commands

using [database name]

Either loads a database from the directory you are currently in or creates a database with the specified name if none exists

Example: using test

create [table name] [columns names]

creates a new table in the database with the specified columns

Example:

create users username password

insert [table name] [columns values]

inserts a new document in the specified table with the values passed

Example:

insert users luis p4ssw0rd

select [columns name or *] From [table name] [where?]

returns an array with the specified columsn from the database

Example:

select username from users

where [key] [operator] [value]

optional parameter for the select command, compares the values from the table with the ones informed using the informed operator

Example:

select username from users where name = luis

Driver

to use this project as a driver, you need to install it on your project, require it from the modules:

const LuisDB = require("learndb");

and then you have access the same same commands from the repl but with objects (kinda like mongodb)

there is only one function currently that transforms the objects into database actions

evalObject

It acepts one parameter that should have this structure:

{
	type: "keyword",
	params: keywordparams
}

I actually have an repo with a test I've made using this database as a driver, this should help understand how it works

https://github.com/ciochetta/testing-luisdb

Driver keywords and params

Using

Params: database name

Example

LuisDB.evalObject({
	type: "using",
	params: "databasename",
});

Using

Params: table, columns

LuisDB.evalObject({
	type: "create",
	params: {
		table: "students",
		columns: ["name", "grade"],
	},
});

Insert

Params: table, document

LuisDB.evalObject({
	type: "insert",
	params: {
		table: "students",
		document: ["luis", 7],
	},
});

To do

These are the things I want to implement in this project, in order of importance

  • write documentation for: UPDATE, DELETE, BULK INSERT, CREATE INDEX
  • move documentation to another file
  • Support indexing
  • Create a CLI for global use
  • Create an authentication system
  • Support partitioning
  • Support migration from SQL schemas

Devlog

I am documenting this project on Dev.to, in this url:

https://dev.to/ciochetta/series/10300

Resources

Every resource I've used to study for this project, not in any particular order:

https://www.stefanjudis.com/today-i-learned/how-to-create-your-own-node-js-repl/

https://nodejs.org/api/repl.html

https://cstack.github.io/db_tutorial/parts/part1.html

https://www.youtube.com/watch?v=WNKw1tiskSM

https://github.com/oguimbal/pgsql-ast-parser

https://youtube.com/watch?v=TOb1tuEZ2X4

learndb's People

Contributors

ciochetta avatar

Stargazers

Alex Shani avatar  avatar Eduardo Rabelo avatar Sibelius Seraphini avatar Jin Yao avatar adamcl avatar Muhammad Faisal Kuchay avatar Raja Azian avatar Berufegōru avatar Abhishek R Chaurasiya avatar salmane avatar Hiroki Iwashita avatar Astitv Singh avatar Le Ngo Duc Anh avatar Farhoud avatar Caio avatar Manan Desai avatar  avatar Sudhir Singh avatar Ruan avatar Sylvester Ezenwata avatar Lawrence Onah avatar Vitor Henrique avatar Ivan Jeremic avatar  avatar Daniel Henrique avatar Femi Ayodeji avatar  avatar

Watchers

 avatar Astitv Singh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.