Meerkat
Meerkat is document database for Node.js built on top of SQLite, which exposes a MongoDB-like API.
Motivation
I make a lot of local-first software for personal use – custom RSS reader, CLI tools, etc. For this kind of work, my go-to database has been SQLite due to its embedded nature.
But I spend a lot of time modelling my database schema because, well, SQLite is an SQL database at the end of the day and I wanted something more Mongo-like, but still embedded.
The core motivation for Meerkat is to build a MongoDB-like API on top of SQLite for Node.js.
Quick Start
import { Database, Document, ObjectID } from "meerkatdb";
// Document generic automatically adds `_id` of type ObjectID (bson)
type TodoDocument = Document<{
title: string;
// All optional keys must have an explicit null type
// Undefined is not valid
description: string | null;
status: "pending" | "in_progress" | "completed";
}>;
const db = new Database(":memory:");
const todoCollection = db.collection<TodoDocument>("todos");
function addTodo({
title,
description,
}: Pick<TodoDocument, "title" | "description"> &
Partial<Pick<TodoDocument, "_id">>) {
const todoId = todoCollection.insertOne({
title,
description,
});
return todoCollection.findOne({ _id: todoId });
}
async function deleteTodo(_id: string) {
todoCollection.deleteOne({
_id,
});
}
const newTodo = addTodo({
title: : "Finish refactoring users module"
})