1.0.7 • Published 3 years ago

learndb v1.0.7

Weekly downloads
10
License
ISC
Repository
github
Last release
3 years ago

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

creates a new table in the database with the specified columns

Example:

create users username password

insert table name

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

Example:

insert users luis p4ssw0rd

select columns name or * From table name

returns an array with the specified columsn from the database

Example:

select username from users

where key 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

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago