npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

learndb

v1.0.7

Published

> My study on how to create a database

Downloads

10

Readme

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