diff --git a/types/pouchdb-core/index.d.ts b/types/pouchdb-core/index.d.ts index a61471ae4b..37c939c7a4 100644 --- a/types/pouchdb-core/index.d.ts +++ b/types/pouchdb-core/index.d.ts @@ -247,7 +247,10 @@ declare namespace PouchDB { type PostDocument = NewDocument & { filters?: {[filterName: string]: string}; - views?: {[viewName: string]: string}; + views?: {[viewName: string]: { + map: string, + reduce?: string + }}; /** You can update an existing doc using _rev */ _rev?: RevisionId; diff --git a/types/pouchdb-core/pouchdb-core-tests.ts b/types/pouchdb-core/pouchdb-core-tests.ts index 911a21e2f7..dc7201dfb8 100644 --- a/types/pouchdb-core/pouchdb-core-tests.ts +++ b/types/pouchdb-core/pouchdb-core-tests.ts @@ -244,6 +244,26 @@ function testRemoteOptions() { }); } +function testViews() { + const db = new PouchDB('dbview'); + db.put({ + _id: '_design/index', + views: { + foo: { + map: 'func(doc){emit(doc.foo)}', + reduce: '_count' + }, + bar: { + map: 'func(doc){emit(doc.bar, doc.buzz)}', + reduce: '_sum' + }, + buzz: { + map: 'func(doc){emit(doc.buzz)}' + } + } + }); +} + function heterogeneousGenericsDatabase(db: PouchDB.Database) { interface Cat { meow: string;