0.0.22 • Published 5 years ago
idx-db v0.0.22
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]
0.0.22
5 years ago
0.0.21
5 years ago
0.0.20
5 years ago
0.0.17-beta.2
5 years ago
0.0.18
5 years ago
0.0.19
5 years ago
0.0.17-beta
5 years ago
0.0.13
5 years ago
0.0.14
5 years ago
0.0.16-alt
5 years ago
0.0.15
5 years ago
0.0.16
5 years ago
0.0.17
5 years ago
0.0.16-beta
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.5
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.4
5 years ago
0.0.1
5 years ago
0.0.0
5 years ago