Skip to content
/ lsdb Public
forked from roberthgnz/lsdb

✨Database powered by localStorage with JSON definition

License

Notifications You must be signed in to change notification settings

stylessh/lsdb

 
 

Repository files navigation

lsdb

CI All Contributors

✨Database powered by localStorage

LIVE DEMO 🔥

Installation

npm i @reliutg/lsdb

With Skypack

no npm install needed!

<script type="module">
  import Lsdb from 'https://cdn.skypack.dev/@reliutg/lsdb';
</script>

We’ll start by setting up a database:

const lsdb = new Lsdb('dbname')

Creating list of collections

lsdb.collection(["categories", "articles"]);

Inserting

lsdb.insert("categories", { title: "Drinks" });
lsdb.insert("categories", { title: "Dinner" });

Getting data

Get all collections

lsdb.all(); 
// {categories: Array(2), articles: Array(0)}

Get a list of documents matching the query

lsdb.find("categories", {
  where: {
    title: { $in: ["er"] },
  },
});

/* 
* [{…}]
*  0:
*   title: "Dinner"
*   _id: // generated id
*/

Get a single document matching the query

lsdb.findOne("categories", {
  where: {
    _id: { $eq: id },
  },
}); // {_id: // generated id, title: "Dinner"}

Removing

Remove a single document matching the query

lsdb.delete("categories", {
  where: {
    _id: { $eq: id },
  },
});

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Aneesh Relan

⚠️ 💻

Zymantas Maumevicius

🚇 💻

Nitkalya Wiriyanuparb

⚠️ 💻

Connor Ruggles

🚇 💻

MAKSS

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

About

✨Database powered by localStorage with JSON definition

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.1%
  • JavaScript 1.9%