Skip to content

Node.js SDK

Opens or creates a database at the given path.

import { FlintDB } from 'flintdb';
const db = FlintDB.open('./mydata');

Parameters:

  • path (string) — directory path for database files

Returns: FlintDB instance

Inserts a document into a collection.

db.put('users', { name: 'Alice', age: 30 });

Parameters:

  • collection (string) — collection name
  • document (object) — JSON document to insert

Retrieves a document by ID.

const user = db.get('users', 'abc123');

Executes a query and returns matching documents.

const results = db.query({
collection: 'users',
filter: { age: { $gte: 18 } },
sort: { name: 'asc' },
limit: 10
});

Parameters:

Returns: Array of matching documents

Returns the number of documents in a collection.

const n = db.count('users');

Closes the database and flushes pending writes.

db.close();