add remove function typings to pouchdb-core (#10754)

This commit is contained in:
Keith D. Moore
2016-08-25 01:28:27 +09:00
committed by Masahiro Wakame
parent 77bc119042
commit d7c91b7a92
2 changed files with 41 additions and 0 deletions
+27
View File
@@ -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<MyModel>;
const id = 'model';
const rev = 'rev';
const db = new PouchDB<MyModel>();
// 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) => {});
}
}
+14
View File
@@ -319,6 +319,20 @@ declare namespace PouchDB {
revision?: Core.RevisionId,
options?: Core.PutOptions): Promise<Core.Response>;
/** Remove a doc from the database */
remove(doc: Core.Document<Content>,
options: Core.Options,
callback: Core.Callback<Core.Error, Core.Response>): void;
remove(docId: Core.DocumentId,
revision: Core.RevisionId,
options: Core.Options,
callback: Core.Callback<Core.Error, Core.Response>): void;
remove(doc: Core.Document<Content>,
options?: Core.Options): Promise<Core.Response>;
remove(docId: Core.DocumentId,
revision: Core.RevisionId,
options?: Core.Options): Promise<Core.Response>;
/** Get database information */
info(options: Core.InfoOptions | void,
callback: Core.Callback<any, Core.DatabaseInfo>): void;