0.4.0 • Published 10 months ago

airdb-lite v0.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

AirDB Lite

Airdb-lite is a light-weight document oriented NoSQL database based on local file-system.

Pure JavaScript NoSQL database with no dependency. Flat file, JSON based document database, written by node.js.

Its api is compatible with the aircode database API.

Features

  • Use JSON file storage, no need to install any database.
  • A convenient and easy-to-use chained API that returns Promises.
  • Powerful combined conditional queries.

Usage

  • Create tables and insert records.
import AirDB from 'airdb-lite';

const db = new AirDB();
const personTable = db.table('person');
const students = [];

function randomScore(low = 0, high = 100) {
  return low + Math.floor(Math.random() * (high - low + 1));
}

for(let i = 0; i < 1000; i++) {
  const student = {name: `student${i}`, score: randomScore()};
  students.push(student);
}
await personTable.save(students);

// find all students that score >= 60
const result = await personTable.where({score: db.gte(60)}).find();
console.log(result);

Database API

Limits

  • Due to the following reasons, it is NOT recommended for use in a production environment:
    • This is just a single-instance text database and does not have the ability to scale across multiple servers.
    • Without using schema constraints and indexes(not implemented yet), the storage performance is limited by the usage of JSON.parse and JSON.stringify. Additionally, the query efficiency is limited by the size of the data.

If you want to deploy your code to a production environment, you can seamlessly migrate to AirCode and use aircode.db.

TODO

  • Table-schema (in dbpath/table.meta)
    • Specifying field types can be used to serialize records in a fast way rather than use JSON.stringify.
  • Indexes (in dbpath/table.meta)
    • Create and use indexes to fastify data querys.
  • Add unit tests
  • Add benchmarks
0.1.0

10 months ago

0.3.0

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.2.3

10 months ago

0.4.0

10 months ago

0.2.2

10 months ago

0.0.1

11 months ago