0.4.4 • Published 6 months ago
@types/pouchdb-live-find v0.4.4
Installation
npm install --save @types/pouchdb-live-find
Summary
This package contains type definitions for pouchdb-live-find (https://github.com/colinskow/pouchdb-live-find).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pouchdb-live-find.
index.d.ts
// Type definitions for pouchdb-live-find 0.4
// Project: https://github.com/colinskow/pouchdb-live-find
// Definitions by: assemblethis <https://github.com/assemblethis>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
/// <reference types="pouchdb-core" />
declare namespace PouchDB {
namespace LiveFind {
interface RequestDef<Content extends {}> extends Pick<Find.FindRequest<Content>, Exclude<keyof Find.FindRequest<Content>, 'use_index'>> {
aggregate?: boolean | undefined; // if true outputs an aggregate list on every update event
}
interface PaginateOptions<Content extends {}> extends Pick<Find.FindRequest<Content>, 'sort' | 'skip'| 'limit'> {}
interface UpdateEvent {
action: 'REMOVE' | 'ADD' | 'UPDATE';
id: any;
rev: any;
doc: any;
}
interface LiveFeed<Content extends {} = {}> {
on(event: 'ready' | 'cancelled', listener: () => void): this;
on(event: 'error', listener: (err: any) => void): this;
on(event: 'update', listener: (event: UpdateEvent, list: any) => void): this;
}
interface LiveFeed<Content extends {} = {}> extends EventEmitter {
// stops the query and removes all listeners
cancel(): void;
// a convenience function to sort any list in place by the sort order you provided. (This will mutate the Array.)
sort(list: []): [];
// updates the pagination and sorting of the aggregate list and immediately returns the updated list. Available options are sort, skip, and limit.
paginate(options: PaginateOptions<Content>): [];
then(callbackSuccess: () => any): void;
catch(callbackFailure: () => any): void;
}
}
interface Database<Content extends {} = {}> {
liveFind(requestDef: LiveFind.RequestDef<Content>): LiveFind.LiveFeed<Content>;
}
}
declare module 'pouchdb-live-find' {
const plugin: PouchDB.Plugin;
export = plugin;
}
Additional Details
- Last updated: Thu, 08 Jul 2021 20:19:47 GMT
- Dependencies: @types/pouchdb-core
- Global values: none
Credits
These definitions were written by assemblethis.