New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

idx-db

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idx-db

a wrapper for indexedDB

latest
npmnpm
Version
0.0.22
Version published
Maintainers
1
Created
Source

Api

import { openDb, add, count, destroy, update, find, all, whereEquals, whereNotEquals, whereContains } from "db";

const structure = [
  {
    version: 1,
    migration(db) {
      // could this have a nicer API?
      const store = db.createObjectStore("todos", {
        keyPath: "id",
        autoIncrement: true,
      });

      store.createIndex("title", "title", { unique: false });
    },
  },
  {
    version: 2,
    migration(db) {
      const store = db.createObjectStore("todos", {
        keyPath: "id",
        autoIncrement: true,
      });

      store.createIndex("done", "done", { unique: false });
    },
  },
];

const db = await openDb("db-name", structure);

// new api. thought this would be better for tree-shaking 🤷‍♂️ need to test it.
//       (db, storeName, arg)
await add(db, 'todos', todo); // Todo
await count(db, 'todos'); // Number
await destroy(db, 'todos', todo); // DeletedTodo
await update(db, 'todos', todo); // Todo
await find(db, 'todos', id); // Todo
await all(db, 'todos'); // [Todo]
await whereEquals(db, 'todos', "title", "hello"); // [Todo]
// should this be added as an arg to whereEquals({ ignoreCase: true }) and others?
await whereContains(db, 'todos', "title", "hello"); // [Todo]
await whereNotEquals(db, 'todos', "title", "hello"); // [Todo

// Pre 0.0.7 mabye?
//const { todos } = db.stores;
//
//await todos.add(todo); // Todo
//await todos.count(); // Number
//await todos.destroy(id); // DeletedTodo
//await todos.update(todo); // Todo
//await todos.find(id); // Todo
//await todos.all(); // [Todo]
//await todos.where("title").equals("hello", { ignoreCase: true }); // [Todo]
//await todos.where("title").contains("hello"); // [Todo]
//await todos.where("title").not.equals("hello"); // [Todo
//await todos.where("done").equals(false); // [Todo]

FAQs

Package last updated on 05 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts