✨Database powered by localStorage
We’ll start by setting up a database:
const lsdb = new Lsdb("lsdb");
lsdb.collection(["categories", "articles"]);
lsdb.insert("categories", { data: { title: "Drinks" } });
lsdb.insert("categories", { data: { title: "Dinner" } });
Get all collections
lsdb.all()
Get all documents
lsdb.get("restaurants")
Get a list of documents matching the query
lsdb.find("categories", {
where: {
field: "title",
operator: "in",
value: "er",
},
})
Get a single document matching the query
lsdb.findOne("categories", {
where: {
field: "title",
operator: "in",
value: "er",
},
})
Remove a single document matching the query
lsdb.remove("restaurants", { name: "Chucha" });