From 646a9b58d363da0110285ee524005ae96c20531d Mon Sep 17 00:00:00 2001 From: Francis Filion Date: Tue, 27 Dec 2016 19:04:25 -0500 Subject: [PATCH] pouchdb-core improvements [bulkDocs, changes, get with open revs] (#13410) * pouchdb-core [BulkDocsOptions, GetOpenRevisions, query, changes promise] * Removed query function to be added in mapreduce. * Added _conflicts to ChangesMeta. --- pouchdb-core/index.d.ts | 14 +++++++++++--- pouchdb-core/pouchdb-core-tests.ts | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pouchdb-core/index.d.ts b/pouchdb-core/index.d.ts index 3b2d044dbc..0fd7eddb37 100644 --- a/pouchdb-core/index.d.ts +++ b/pouchdb-core/index.d.ts @@ -201,7 +201,12 @@ declare namespace PouchDB { }[]; } + interface BulkDocsOptions extends PutOptions { + new_edits?: boolean; + } + interface ChangesMeta { + _conflicts?: RevisionId[]; _deleted?: boolean; _attachments?: Attachments; } @@ -286,7 +291,7 @@ declare namespace PouchDB { results: ChangesResponseChange[]; } - interface Changes extends EventEmitter { + interface Changes extends EventEmitter, Promise> { on(event: 'change', listener: (value: ChangesResponseChange) => any): this; on(event: 'complete', listener: (value: ChangesResponse) => any): this; on(event: 'error', listener: (value: any) => any): this; @@ -320,6 +325,9 @@ declare namespace PouchDB { * revisions specified in open_revs array. Leaves will be returned * in the same order as specified in input array. */ open_revs: 'all' | Core.RevisionId[]; + + /** Include revision history of the document. */ + revs?: boolean; } /** @todo does this have any other properties? */ @@ -465,7 +473,7 @@ declare namespace PouchDB { * Finally, to delete a document, include a _deleted parameter with the value true. */ bulkDocs(docs: Core.PutDocument[], - options: Core.PutOptions | null, + options: Core.BulkDocsOptions | null, callback: Core.Callback): void; /** @@ -476,7 +484,7 @@ declare namespace PouchDB { * Finally, to delete a document, include a _deleted parameter with the value true. */ bulkDocs(docs: Core.PutDocument[], - options?: Core.PutOptions): Promise; + options?: Core.BulkDocsOptions): Promise; /** Compact the database */ compact(options?: Core.CompactOptions): Promise; diff --git a/pouchdb-core/pouchdb-core-tests.ts b/pouchdb-core/pouchdb-core-tests.ts index 965ec981fe..1901f38245 100644 --- a/pouchdb-core/pouchdb-core-tests.ts +++ b/pouchdb-core/pouchdb-core-tests.ts @@ -175,5 +175,7 @@ namespace PouchDBCoreTests { heartbeat: false, filter: (doc: any, params: any) => {} }); + + db.changes({ limit: 50 }).then(() => {}); } }