Primitive database with Rust.

Related tags

Database cursorsql
Overview

CQL Banner

CursorsQL is a primitive but intuitive database in Rust for beginners.


Introduction

CursorsQL is a small database that is easy to learn and use. It is intended for use by people who are newcomers to database technology and SQL.

By design, CursorsQL are minimal and simple, and limited. Even though there are some conveniences CQL offers, CQL is just a stepping stone to true SQL databases like MySQL, SQLite, and PostgresQL,

Unlike the past slow.db and css.db, this project is an actual useable and feasible database that is fast and complete for beginners to database technology.

If something's wrong or doesn't work how you feel, you can open an issue.

Documentation is available here.

Consumption and usage

CursorsDB and CQL are available in one package named @cursorsdottsx/cursorsql, so you can install them with either npm or yarn, or any other package manager.

NPM:

$ npm install @cursorsdottsx/cursorsql

Yarn:

$ yarn add @cursorsdottsx/cursorsql

The package also comes with a CLI you can use by installing the package globally and executing cql or using npx cql.

Types for TypeScript are included as the project frontend is in TypeScript.

There is some configuration and setup required before you use CQL and the database driver, though.

  • First you'll need to use cql config to set up CursorsDB.
  • Next, use cql to use the CLI.
  • Create a new database with the CLI.
  • Use the database driver and connect to the database.

Example usage:

import CQLClient from "@cursorsdottsx/cursorsql";

const client = new CQLClient("cql connection string");

await new Promise((resolve, reject) => {
    client.on("ready", () => {
        console.log("Connected to CursorsQL!");

        return resolve();
    });
});

CursorsQL

Introduction

CQL has 6 different kinds of statements and only supports basic CRUD. They are as follows:

  • select Reading from the database
  • create Creating a new table
  • insert Inserting into a table
  • upsert Upserting into a table
  • update Updating a table
  • delete Deleting from a table

Types

CQL supports many primitive types and arrays along with nullables.

  • i8 8 bit integer
  • i16 16 bit integer
  • i32 32 bit integer
  • i64 64 bit integer
  • u8 unsigned 8 bit integer
  • u16 unsigned 16 bit integer
  • u32 unsigned 32 bit integer
  • u64 unsigned 64 bit integer
  • f32 32 bit IEEE-754 floating point
  • f64 64 bit IEEE-754 floating point
  • bool boolean
  • str string
  • null null

Suffixing a type with ? will make the type nullable.

Constraints

CQL also has a few column constraints.

The constraints are:

  • max can be used to enforce a max value for numbers or max length for strings
  • min can be used to enforce a min value for numbers or min length for strings
  • unique can be used to enforce a unique column

Modifiers

In addition to constraints, CQL also supports modifiers after a select statement.

Modifiers will modify the output a select statement produces.

Currently, all supported modifiers are:

  • order will try to order the results as best as it can (1 for ascending and -1 for descending)
  • sort will sort the results by a column (1 for ascending and -1 for descending)
  • limit will limit the result count to a maximum value

Syntax

create

create =
'create'
    table
'{'
    ( col type ( ( ( 'max' | 'min' ) number ) | 'unique' )* ',' )*
    ( col type ( ( ( 'max' | 'min' ) number ) | 'unique' )* ( ',' )? )
'}'
';' ;

insert

insert =
'insert'
    table
'{'

    ( '{'
        ( col ( string | number | boolean ) ',' )*
        ( col ( string | number | boolean ) ( ',' )? )
    '}' ',' )*
    ( '{'
        ( col ( string | number | boolean ) ',' )*
        ( col ( string | number | boolean ) ( ',' )? )
    '}' ( ',' )? )
'}'
';' ;

select

select =
'select'
    ( '*' | '{' ( col ',' )* ( col ( ',' )? ) '}' )
'from'
    table
( 'where' '{'
    ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ',' )*
    ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ( ',' )? )
'}' )?
( ( 'sort' | 'order' | 'limit' ) number )*
';' ;

update

update =
'update'
    table
'{'
    ( col ( string | number | boolean ) ',' )*
    ( col ( string | number | boolean ) ( ',' )? )
'}'
( 'where' '{'
    ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ',' )*
    ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ( ',' )? )
'}' )?
';' ;

upsert

upsert =
'upsert'
    table
'{'
    ( col ( string | number | boolean ) ',' )*
    ( col ( string | number | boolean ) ( ',' )? )
'}'
'{'
    ( col ( string | number | boolean ) ',' )*
    ( col ( string | number | boolean ) ( ',' )? )
'}'
( 'where' '{'
    ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ',' )*
    ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ( ',' )? )
'}' )?
';' ;

delete

delete =
'delete'
    table
(
    ( 'where' '{'
        ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ',' )*
        ( col ( '=' | '!' | '>' | '>=' | '<' | '<=' ) ( string | number | boolean ) ( ',' )? )
    '}' )?
    ( ( 'sort' | 'order' | 'limit' ) number )*
)?
';' ;

CursorsML

CursorsML is a really simple markup language with little syntax that CursorsDB uses to store metadata.

In the future, more syntax and semantics will be added to provide more efficient methods of storing data.

The documentation has more information on CursorsML.

Contributing

Requirements

  • Node.js v16 or newer
  • Rust v1.58 or newer

First, install all dependencies with either NPM or Yarn.

NPM:

$ npm install

Yarn:

$ yarn

Next, install dependencies inside the server.

$ cd server/
$ cargo build

Then, create your changes and commit them.

Finally, open a pull request!

You might also like...

:rocket: One command to generate REST APIs for any MySql Database.

:rocket: One command to generate REST APIs for any MySql Database.

Xmysql : One command to generate REST APIs for any MySql database Why this ? Generating REST APIs for a MySql database which does not follow conventio

Dec 30, 2022

Realtime database backend based on Operational Transformation (OT)

Realtime database backend based on Operational Transformation (OT)

This README is for [email protected]. For [email protected], see the 1.x-beta branch. To upgrade, see the upgrade guide. ShareDB ShareDB is a realtime databa

Dec 29, 2022

A transparent, in-memory, streaming write-on-update JavaScript database for Small Web applications that persists to a JavaScript transaction log.

JavaScript Database (JSDB) A zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to

Nov 13, 2022

The JavaScript Database, for Node.js, nw.js, electron and the browser

The JavaScript Database, for Node.js, nw.js, electron and the browser

The JavaScript Database Embedded persistent or in memory database for Node.js, nw.js, Electron and browsers, 100% JavaScript, no binary dependency. AP

Jan 2, 2023

Bluzelle is a smart, in-memory data store. It can be used as a cache or as a database.

SwarmDB ABOUT SWARMDB Bluzelle brings together the sharing economy and token economy. Bluzelle enables people to rent out their computer storage space

Dec 31, 2022

The ultimate solution for populating your MongoDB database.

The ultimate solution for populating your MongoDB database.

Mongo Seeding The ultimate solution for populating your MongoDB database πŸš€ Define MongoDB documents in JSON, JavaScript or even TypeScript files. Use

Dec 29, 2022

Node.js client for the Aerospike database

Aerospike Node.js Client An Aerospike add-on module for Node.js. The client is compatible with Node.js v8.x, v10.x (LTS), v12.x (LTS), and v14.x (LTS)

Dec 30, 2022

Common Database Interface for Node

database-js Wrapper for multiple databases with a JDBC-like connection Database-js implements a common, promise-based interface for SQL database acces

Dec 3, 2022

NodeJS PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.

Node Postgres Extras NodeJS port of Heroku PG Extras with several additions and improvements. The goal of this project is to provide powerful insights

Nov 14, 2022
Owner
youdateme
professional typescript simp with big dreams and cursed things
youdateme
DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB database, such as: connecting to the database, executing scripts, calling functions, uploading variables, etc.

DolphinDB JavaScript API English | δΈ­ζ–‡ Overview DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB

DolphinDB 6 Dec 12, 2022
A template of Rust + WebAssembly with TypeScript (πŸ¦€ + πŸ•ΈοΈ = πŸ’–)

rust-wasm-ts-template This repository is a template of Rust + WebAssembly with TypeScript ( ?? + ??️ = ?? ). Requirements The Rust Toolchain wasm-pack

Chris Ohk 20 Aug 26, 2022
πŸ”„ A realtime Database for JavaScript Applications

RxDB A realtime Database for JavaScript Applications RxDB (short for Reactive Database) is a NoSQL-database for JavaScript Applications like Websites,

Daniel Meyer 18.6k Dec 31, 2022
⚑️ lowdb is a small local JSON database powered by Lodash (supports Node, Electron and the browser)

Lowdb Small JSON database for Node, Electron and the browser. Powered by Lodash. ⚑ db.get('posts') .push({ id: 1, title: 'lowdb is awesome'}) .wri

null 18.9k Dec 30, 2022
:koala: - PouchDB is a pocket-sized database.

PouchDB – The Database that Syncs! PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the br

PouchDB 15.4k Dec 30, 2022
Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!

PostGraphile Instant lightning-fast GraphQL API backed primarily by your PostgreSQL database. Highly customisable and extensible thanks to incredibly

Graphile 11.7k Jan 4, 2023
πŸ‰ Reactive & asynchronous database for powerful React and React Native apps ⚑️

A reactive database framework Build powerful React and React Native apps that scale from hundreds to tens of thousands of records and remain fast ⚑️ W

Nozbe 8.8k Jan 5, 2023
Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.

Lovefield Lovefield is a relational database written in pure JavaScript. It provides SQL-like syntax and works cross-browser (currently supporting Chr

Google 6.8k Jan 3, 2023
AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.

Please use version 1.x as prior versions has a security flaw if you use user generated data to concat your SQL strings instead of providing them as a

Andrey Gershun 6.1k Jan 9, 2023
Realm is a mobile database: an alternative to SQLite & key-value stores

Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript versions of Realm. Currently we s

Realm 5.1k Jan 3, 2023