Skip to content

Commit

Permalink
nudge: expand bulkDocs overloads (related to #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
AGBrown committed Apr 30, 2015
1 parent 6bfab97 commit 3110b77
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
46 changes: 27 additions & 19 deletions pouchdb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,22 @@ declare module pouchdb {

/** Contains the method and call/return types for bulkDocs() */
module bulkDocs {
/** Options for bulk docs */
interface Options<D> 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<ExistingDoc>, callback?: async.Callback<OperationResponse[]>): void;
/**
* Update/Delete each doc in an array of documents.
* @param doc the doc
Expand All @@ -231,6 +241,12 @@ declare module pouchdb {
*/
bulkDocs(doc: ExistingDoc[], options: options.EmptyOptions, callback?: async.Callback<OperationResponse[]>): void;

/**
* Create multiple documents.
* @param doc the doc
* @todo define options shape - docs don't make it clear what this is
*/
bulkDocs(doc: Options<NewDoc>, callback?: async.Callback<OperationResponse[]>): void;
/**
* Create multiple documents.
* @param doc the doc
Expand All @@ -245,33 +261,25 @@ declare module pouchdb {
*/
bulkDocs(doc: NewDoc[], options: options.EmptyOptions, callback?: async.Callback<OperationResponse[]>): 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<OperationResponse[]>): 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<OperationResponse[]>): 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<MixedDoc>, callback?: async.Callback<OperationResponse[]>): 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<OperationResponse[]>): void;
bulkDocs(doc: MixedDoc[], callback?: async.Callback<OperationResponse[]>): 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<OperationResponse[]>): void;
bulkDocs(doc: MixedDoc[], options: options.EmptyOptions, callback?: async.Callback<OperationResponse[]>): void;
}
/** Promise pattern for bulkDocs() */
interface Promise {
Expand Down
28 changes: 14 additions & 14 deletions tests/integration/test.basics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3110b77

Please sign in to comment.