Awesome Open Source
Awesome Open Source

phodb

Simplest database interface for chrome extension storage

  • Simple built-in methods
  • Faster with storage cached of table
  • Support UUID
  • Support @types
  • Can extend for other simple storages

Usage

npm i phodb -S
import { ChromeExtDb } from "phodb";

const db = new ChromeExtDb();
const peopleTable = db.table("people");

peopleTable.where(x => !!x).then(res => console.log(res));
peopleTable
  .findOne(x => new Date(x.createdAt) < new Date())
  .then(res => console.log(res));

Documents

class ChromeExtDb implements IPhoDb {
  constructor(options?: {
    setFunc: (localData: any) => void;
    getFunc: (callback: (data: any) => void) => void;
  });
  table<T>(name: string): ITable<T>;
}

class ChromeExtTable<T> implements ITable<T> {
  constructor(
    name: string,
    setFunc: (localData: any) => void,
    getFunc: (res: any) => void
  );
  add(model: T): Promise<T & BaseModel>;
  remove(id: string): Promise<boolean>;
  update(id: string, model: T & BaseModel): Promise<T & BaseModel | null>;
  findOne(pre: (model: T & BaseModel) => boolean): Promise<T & BaseModel>;
  where(pre: (model: T & BaseModel) => boolean): Promise<(T & BaseModel)[]>;
  list(): Promise<(T & BaseModel)[]>;
  getName(): string;
}

interface BaseModel {
    id: string;
    createdAt: number;
    updateAt: number;
}

Browser & js built file

https://github.com/jinhduong/phodb/blob/master/build/release/phodb.chrome.js

var peopleTable = ChromeExt.table("people");
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Typescript (240,386
Database (93,032
Chrome Extension (9,607
Uuid (3,114
Typescript Library (468
Storage Engine (303
Database Adapter (139