airdb-lite
v0.4.0
Published
Airdb-lite is a light-weight document oriented NoSQL database based on local file-system.
Downloads
18
Readme
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
- Table
- Query Commands
- Sort and Pagination Chain
- Projection Chain
- Update Chain
- Logical Chain
- Comparison Operators
- Element Operators
- Evaluation Operators
- Array Operators
- Bitwise Operators
- ~~Geospatial Objects~~
- ~~Point~~
- ~~LineString~~
- ~~Polygon~~
- ~~MultiPoint~~
- ~~MultiLineString~~
- ~~MultiPolygon~~
- ~~GeometryCollection~~
- ~~Geospatial Operators~~
- ~~db.geoIntersects(conditions)~~
- ~~db.geoWithin(conditions)~~
- ~~db.near(conditions)~~
- ~~db.nearSphere(conditions)~~
- Update Operators
- Logical Operators
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