Doculite uses a Firestore-like syntax for data management. Collections are automatically created as SQLite tables upon the first document insertion.
To interact with data, you first create a reference to a document using db.collection(name).doc(id). If you do not provide an ID to .doc(), the ID is optional (though the example suggests it may be generated or handled by the library). Documents must be valid JavaScript objects that can be parsed to JSON.
// 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" });