PouchDB: Fix views type in post and put (#35938)

This commit is contained in:
Abdel-Rahman A
2019-06-20 00:37:39 +02:00
committed by Daniel Rosenwasser
parent 984e42db6f
commit 6cce0bd772
2 changed files with 24 additions and 1 deletions

View File

@@ -247,7 +247,10 @@ declare namespace PouchDB {
type PostDocument<Content extends {}> = NewDocument<Content> & {
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;

View File

@@ -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;