# phodb

> simplest db for chrome extension

Latest version **1.0.8** (published 2019-05-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install phodb
pnpm add phodb
yarn add phodb
bun add phodb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2019-05-14 |
| First published | 2019-05-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | jinhduong |
| Maintainers | jinhduong |
| Keywords | phodb |

## Links

- npm: https://www.npmjs.com/package/phodb
- Repository: https://github.com/jinhduong/phodb
- Homepage: https://github.com/jinhduong/phodb#readme
- Issues: https://github.com/jinhduong/phodb/issues
- npm.io page: https://npm.io/package/phodb

## Recent versions

- 1.0.8 (latest) — 2019-05-14
- 1.0.6 — 2019-05-13
- 1.0.5 — 2019-05-13
- 1.0.4 — 2019-05-13
- 1.0.3 — 2019-05-13
- 1.0.2 — 2019-05-13
- 1.0.0 — 2019-05-13

## README

# phodb

![](https://api.travis-ci.org/jinhduong/phodb.svg?branch=dev)

## 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
```

```ts
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

```ts
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
```js
var peopleTable = ChromeExt.table("people");
```

---
_Source: https://npm.io/package/phodb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
