Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @flow
- export type PouchDBPostResponse = { ok: true, id: string, rev: string }
- export type PouchDBUpsertResponse = { updated: true, id: string, rev: string } | { updated: false }
- export type PouchDBRemoveResponse = { ok: true, id: string, rev: string, } | { ok: false }
- export type PouchDBFindResponse<T> = { docs: Array<T>, warning?: string }
- export type PouchDBAllDocsResponse<T> = { rows: Array<{ doc: T, id: string, key: string, value: { rev: string } }>, total_rows: number }
- export type PouchError = { // empirically found
- docId: string,
- error: boolean,
- message: string,
- name: string,
- reason: string,
- status: number
- }
- declare module 'pouchdb-browser' {
- declare export default typeof PouchDB
- declare class PouchDB<K> {
- static plugin(any): void;
- constructor(name: string): void;
- destroy(): void;
- allDocs({ includeDocs?: boolean }): Promise<PouchDBAllDocsResponse<K>>;
- get(docId: string): K;
- remove(docId: string): Promise<PouchDBRemoveResponse>;
- post(doc: K, options?: {}): Promise<PouchDBPostResponse>;
- find({
- selector: {
- [$Keys<K>]: { $eq: any } // more to add, of course!
- }
- }): Promise<PouchDBFindResponse<K>>;
- // requires pouchd-upsert
- upsert(docId: string, (doc: K) => K | false): Promise<PouchDBUpsertResponse>;
- }
- }
Add Comment
Please, Sign In to add comment