From d7c91b7a92d4e42ca50d375454b869e06bb80bb3 Mon Sep 17 00:00:00 2001 From: "Keith D. Moore" Date: Wed, 24 Aug 2016 11:28:27 -0500 Subject: [PATCH] add remove function typings to pouchdb-core (#10754) --- pouchdb-core/pouchdb-core-tests.ts | 27 +++++++++++++++++++++++++++ pouchdb-core/pouchdb-core.d.ts | 14 ++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/pouchdb-core/pouchdb-core-tests.ts b/pouchdb-core/pouchdb-core-tests.ts index ac7a6c3e69..71f5db7d63 100644 --- a/pouchdb-core/pouchdb-core-tests.ts +++ b/pouchdb-core/pouchdb-core-tests.ts @@ -75,4 +75,31 @@ namespace PouchDBCoreTests { db.info({ ajax: { cache: true }}, (error, result) => { }); } + + function testRemove() { + type MyModel = { rev: 'rev', property: 'someProperty '}; + let model: PouchDB.Core.Document; + const id = 'model'; + const rev = 'rev'; + + const db = new PouchDB(); + + // Promise version with doc + db.remove(model).then( (res: PouchDB.Core.Response) => {}); + + // Promise version with doc and options + db.remove(model, {}).then( (res: PouchDB.Core.Response) => {}); + + // Promise version with docId and rev + db.remove(id, rev).then( (res: PouchDB.Core.Response) => {}); + + // Promise version with docId and rev and options + db.remove(id, rev, {}).then( (res: PouchDB.Core.Response) => {}); + + // Callback version with doc + db.remove(model, {}, (res: PouchDB.Core.Response) => {}); + + // Callback version with docId and rev + db.remove(id, rev, {}, (res: PouchDB.Core.Response) => {}); + } } diff --git a/pouchdb-core/pouchdb-core.d.ts b/pouchdb-core/pouchdb-core.d.ts index a8b6418510..1a56e51785 100644 --- a/pouchdb-core/pouchdb-core.d.ts +++ b/pouchdb-core/pouchdb-core.d.ts @@ -319,6 +319,20 @@ declare namespace PouchDB { revision?: Core.RevisionId, options?: Core.PutOptions): Promise; + /** Remove a doc from the database */ + remove(doc: Core.Document, + options: Core.Options, + callback: Core.Callback): void; + remove(docId: Core.DocumentId, + revision: Core.RevisionId, + options: Core.Options, + callback: Core.Callback): void; + remove(doc: Core.Document, + options?: Core.Options): Promise; + remove(docId: Core.DocumentId, + revision: Core.RevisionId, + options?: Core.Options): Promise; + /** Get database information */ info(options: Core.InfoOptions | void, callback: Core.Callback): void;