diff --git a/pouchdb.d.ts b/pouchdb.d.ts index 0048b5c..c8a405c 100644 --- a/pouchdb.d.ts +++ b/pouchdb.d.ts @@ -211,12 +211,22 @@ declare module pouchdb { /** Contains the method and call/return types for bulkDocs() */ module bulkDocs { + /** Options for bulk docs */ + interface Options extends options.EmptyOptions { + docs: D[] + } /** * Callback pattern for bulkDocs() * @todo a mixed doc array for mixed CUD updates * @todo new_edits */ - interface Callback { + interface Callback { + /** + * Update/Delete each doc in an array of documents. + * @param doc the doc + * @todo define options shape - docs don't make it clear what this is + */ + bulkDocs(options: Options, callback?: async.Callback): void; /** * Update/Delete each doc in an array of documents. * @param doc the doc @@ -231,6 +241,12 @@ declare module pouchdb { */ bulkDocs(doc: ExistingDoc[], options: options.EmptyOptions, callback?: async.Callback): void; + /** + * Create multiple documents. + * @param doc the doc + * @todo define options shape - docs don't make it clear what this is + */ + bulkDocs(doc: Options, callback?: async.Callback): void; /** * Create multiple documents. * @param doc the doc @@ -245,33 +261,25 @@ declare module pouchdb { */ bulkDocs(doc: NewDoc[], options: options.EmptyOptions, callback?: async.Callback): void; - ///** - // * Mixed operations on an array of documents - // * @param doc the doc - // * @todo define options shape - docs don't make it clear what this is - // */ - //bulkDocs(doc: MixedDoc[], callback?: async.Callback): void; - ///** - // * Mixed operations on an array of documents - // * @param doc the doc - // * @param options - // * @todo define options shape - docs don't make it clear what this is - // */ - //bulkDocs(doc: MixedDoc[], options: options.EmptyOptions, callback?: async.Callback): void; - /** - * Create multiple documents. + * Perform mixed Create/Update/Delete operations on multiple documents. + * @param options the doc + * @todo define options shape - docs don't make it clear what this is + */ + bulkDocs(options: Options, callback?: async.Callback): void; + /** + * Perform mixed Create/Update/Delete operations on multiple documents. * @param doc the doc * @todo define options shape - docs don't make it clear what this is */ - bulkDocs(doc: BaseDoc[], callback?: async.Callback): void; + bulkDocs(doc: MixedDoc[], callback?: async.Callback): void; /** - * Create multiple documents. + * Perform mixed Create/Update/Delete operations on multiple documents. * @param doc the doc * @param options * @todo define options shape - docs don't make it clear what this is */ - bulkDocs(doc: BaseDoc[], options: options.EmptyOptions, callback?: async.Callback): void; + bulkDocs(doc: MixedDoc[], options: options.EmptyOptions, callback?: async.Callback): void; } /** Promise pattern for bulkDocs() */ interface Promise { diff --git a/tests/integration/test.basics.ts b/tests/integration/test.basics.ts index b8648e6..3e1f7b8 100644 --- a/tests/integration/test.basics.ts +++ b/tests/integration/test.basics.ts @@ -422,20 +422,20 @@ adapters.forEach((adapter: string) => { // }); //}); - //it('Bulk docs', function (done) { - // var db = new PouchDB(dbs.name); - // db.bulkDocs({ - // docs: [ - // { test: 'somestuff' }, - // { test: 'another' } - // ] - // }, function (err, infos) { - // infos.length.should.equal(2); - // infos[0].ok.should.equal(true); - // infos[1].ok.should.equal(true); - // done(); - // }); - //}); + it('Bulk docs', function (done) { + var db = new PouchDB(dbs.name, (e, v) => { }); + db.bulkDocs({ + docs: [ + { test: 'somestuff' }, + { test: 'another' } + ] + }, function (err, infos) { + expect(infos.length).to.equal(2); + expect(infos[0].ok).to.equal(true); + expect(infos[1].ok).to.equal(true); + done(); + }); + }); // See: https://github.com/AGBrown/pouchdb.d.ts/issues/4 it('Bulk docs - api version', function (done) {