JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q53917F
  • License MIT

A tiny javascript in memory database with indexing and filters.

Package Exports

  • pixiedb

Readme

PixieDB

npm version npm downloads bundle JSDocs License

A tiny javascript in memory database with indexing and filters.

import { PixieDb } from "pixiedb";

const products = [
    { id: 1, name: "Apple", price: 5, category: "Fruit" },
    { id: 2, name: "Banana", price: 10, category: "Fruit" },
    { id: 3, name: "Grapes", price: 6, category: "Fruit" },
    { id: 4, name: "Orange", price: 8, category: "Fruit" },
    { id: 5, name: "Potato", price: 18, category: "Vegetable" },
    { id: 6, name: "Milk", price: 7, category: "Dairy" },
]

// provide unique key, data and indexes for better performance
// 3rd param data is optional can be load after using the load method
const pdb = new PixieDb('id', ["price", "category"], products) 

// to load data later
pdb.load(products)

const byId = d.select().$eq("id", 2).single()
console.log(byId);
// { id: 2, name: "Banana", price: 10, category: "Fruit" }

// can also pass array of fields to select method to pick only those fields/properties
const fruitBelow10 = d.select("id", "name", "price").$eq("category", "Fruit").$lte("price", 10).orderBy("name", ["price", "desc"]).from(3).limit(3).data()
console.log(fruitBelow10); // [{ id: 1, name: "Apple", price: 10 }, ...]

const updatedBanana = d.where().$eq("name", "Banana").update({price: 100})
const deletedApples = d.where().$eq("name", "Apple").delete()