DocuLite lets you use SQLite like Firebase Firestore. It’s written in Typescript and an adapter on top of sqlite3 and sqlite. It support listeners on documents, collections, and basic queries. Feedback & Bugs to thedoculite@gmail.com.
This is early work, so please treat it appropriately.
1. Initialize a DB
Example:
import { Database } from "doculite"
const db = new Database();
2. Create Collections and Set Documents
Collections are created on first insertion of a document. They are represented by a SQLite Table.
// create ref to the doc. Doc ID optional.
const usersRef = db.collection("users").doc("123");
const refWithoutId = db.collection("users").doc();
// Any valid Javascript object that can be parsed to valid JSON can be inserted as a document.
await usersRef.set({ username: "John Doe", createdAt: "123", updatedAt: "123" });
await refWithoutId.set({ username: "Jane Doe" });
3. Get a particular document
// define ref
const usersRef = db.collection("users").doc("123");
// get
const user = await usersRef.get();
// print
console.log(user); // prints { username: "John Doe" };
4. Update Documents in Collections
// ref
const usersRef = db.collection("users").doc("123");
// Properties existing on both old and