Skip to content

Commit

Permalink
(#46) - Add the id on the return of the updated:false response
Browse files Browse the repository at this point in the history
…to align with the docs and the `updated:true` flow.

fixes #46
  • Loading branch information
HauptmannEck authored and nolanlawson committed Mar 21, 2017
1 parent a5db122 commit ff2a6e6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/pouchdb.upsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function upsertInner(db, docId, diffFun) {
if (!newDoc) {
// if the diffFun returns falsy, we short-circuit as
// an optimization
return { updated: false, rev: docRev };
return { updated: false, rev: docRev, id: docId };
}

// users aren't allowed to modify these values,
Expand Down
2 changes: 1 addition & 1 deletion dist/pouchdb.upsert.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function upsertInner(db, docId, diffFun) {
if (!newDoc) {
// if the diffFun returns falsy, we short-circuit as
// an optimization
return { updated: false, rev: docRev };
return { updated: false, rev: docRev, id: docId };
}

// users aren't allowed to modify these values,
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function tests(dbName, dbType) {
}).then(function (res) {
res.updated.should.equal(false);
res.rev.should.match(/1-/);
res.id.should.equal('myid');
return db.get('myid');
}).then(function (doc) {
should.exist(doc._rev);
Expand Down

0 comments on commit ff2a6e6

Please sign in to comment.