mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Update and lint pouchdb-mapreduce
This commit is contained in:
Vendored
+15
-12
@@ -1,15 +1,18 @@
|
||||
// Type definitions for pouchdb-mapreduce v6.1.2
|
||||
// Type definitions for pouchdb-mapreduce 6.1
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Simon Paulger <https://github.com/spaulg>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="pouchdb-core" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
// TODO: Fixing this lint error will require a large refactor
|
||||
/* tslint:disable:no-single-declare-module */
|
||||
|
||||
declare namespace PouchDB {
|
||||
interface Filter {
|
||||
map: (doc: any) => void;
|
||||
reduce?: (key: string, value: any) => any;
|
||||
map(doc: any): void;
|
||||
reduce?(key: string, value: any): any;
|
||||
}
|
||||
|
||||
namespace Query {
|
||||
@@ -55,19 +58,19 @@ declare namespace PouchDB {
|
||||
stale?: 'ok' | 'update_after';
|
||||
}
|
||||
|
||||
interface Response<Content extends Core.Encodable> {
|
||||
interface Response<Content extends {}> {
|
||||
total_rows: number;
|
||||
offset: number;
|
||||
rows: {
|
||||
rows: Array<{
|
||||
id: any;
|
||||
key: any;
|
||||
value: any;
|
||||
doc?: Core.ExistingDocument<Content & Core.AllDocsMeta>;
|
||||
}[]
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Database<Content extends Core.Encodable> {
|
||||
interface Database<Content extends {} = {}> {
|
||||
/**
|
||||
* Cleans up any stale map/reduce indexes.
|
||||
*
|
||||
@@ -76,7 +79,7 @@ declare namespace PouchDB {
|
||||
* to take up space on disk. viewCleanup() removes these unnecessary
|
||||
* index files.
|
||||
*/
|
||||
viewCleanup(callback: PouchDB.Core.Callback<any,Core.BasicResponse>): void;
|
||||
viewCleanup(callback: PouchDB.Core.Callback<Core.BasicResponse>): void;
|
||||
/**
|
||||
* Cleans up any stale map/reduce indexes.
|
||||
*
|
||||
@@ -91,17 +94,17 @@ declare namespace PouchDB {
|
||||
* Invoke a map/reduce function, which allows you to perform more complex queries
|
||||
* on PouchDB than what you get with allDocs().
|
||||
*/
|
||||
query(fun: string | Filter | Function, opts: Query.Options, callback: (err: Core.Error, res: Query.Response<Content>) => void): void;
|
||||
query<Model>(fun: string | Filter | ((doc: any) => void), opts: Query.Options, callback: (err: Core.Error, res: Query.Response<Content & Model>) => void): void;
|
||||
/**
|
||||
* Invoke a map/reduce function, which allows you to perform more complex queries
|
||||
* on PouchDB than what you get with allDocs().
|
||||
*/
|
||||
query(fun: string | Filter | Function, callback: (err: Core.Error, res: Query.Response<Content>) => void): void;
|
||||
query<Model>(fun: string | Filter | ((doc: any) => void), callback: (err: Core.Error, res: Query.Response<Content & Model>) => void): void;
|
||||
/**
|
||||
* Invoke a map/reduce function, which allows you to perform more complex queries
|
||||
* on PouchDB than what you get with allDocs().
|
||||
*/
|
||||
query(fun: string | Filter | Function, opts?: Query.Options): Promise<Query.Response<Content>>;
|
||||
query<Model>(fun: string | Filter | ((doc: any) => void), opts?: Query.Options): Promise<Query.Response<Content & Model>>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
interface MyModel {
|
||||
numericProperty: number;
|
||||
}
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
|
||||
let db = new PouchDB<MyModel>('mydb');
|
||||
@@ -8,14 +10,14 @@ function testConstructor() {
|
||||
}
|
||||
|
||||
function testQuery() {
|
||||
let pouch = new PouchDB<{}>('mydb');
|
||||
let pouch = new PouchDB('mydb');
|
||||
// find pokemon with name === 'Pika pi!'
|
||||
pouch.query('my_index/by_name', {
|
||||
key : 'Pika pi!',
|
||||
include_docs : true
|
||||
}).then(function (result) {
|
||||
}).then((result) => {
|
||||
// handle result
|
||||
}).catch(function (err) {
|
||||
}).catch((err) => {
|
||||
// handle errors
|
||||
});
|
||||
|
||||
@@ -25,10 +27,9 @@ function testQuery() {
|
||||
endkey : 'P\uffff',
|
||||
limit : 5,
|
||||
include_docs : true
|
||||
}).then(function (result) {
|
||||
}).then((result) => {
|
||||
// handle result
|
||||
}).catch(function (err) {
|
||||
}).catch((err) => {
|
||||
// handle errors
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user