2.0.2 • Published 3 years ago

polodb v2.0.2

Weekly downloads
21
License
MIT
Repository
github
Last release
3 years ago

PoloDB Node.js Client

npm version

PoloDB is a lightweight JSON-based database.

Features

  • Simple and Lightweight
    • Only cost ~500kb memory to serve a database
    • The database server binary is less than 2Mb
    • Store data in one file
  • Easy to learn and use
    • NoSQL
    • MongoDB-like API
  • Various language bindings
  • Standalone Process
    • Process isolation
    • Asynchronous IO
  • Cross-Platform
    • Working on common OS

Install

Npm:

npm install --save polodb

Yarn:

yarn add polodb

Open a database

import { PoloDbClient } from 'polodb';

async function main() {
  const db = await PoloDbClient.createConnection('./test.db);
}

Remember to close the database.

db.dispose();

Create a Collection

Create a collection.

await db.createCollection('students');

Insert

Insert a document to the database.

const collection = db.collection('students');

await collection.insert({
    name: 'Vincent Chan',
    age: 14,
});

Find

Find documents in the database.

const collection = db.collection('students');

const result = await collection.find({
    name: 'Vincent Chan',
});

console.log(result);

Advanced Find

PoloDB supports complex find operation like MongoDB.

Example: find all items with age is greater than 18

const collection = db.collection('students');

const result = await collection.find({
    age: {
        $gt: 18,
    },
});

Update

Update documents in the database.

const collection = db.collection('students');

await collection.update({
    name: 'Vincent Chan',
}, {
    $inc: {
        age: 1,
    },
});

Delete

Delete documents by query.

const collection = db.collection('students');

await collection.delete({
    name: 'Vincent Chan',
});
2.0.2

3 years ago

0.10.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

0.10.0

3 years ago

0.8.0

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago