Skip to content

Commit

Permalink
couchdb: Fixes query for document existance
Browse files Browse the repository at this point in the history
The originaly implementation did not properly take into account the
promise returned from the maybe function querying the document.  This
resulted in a promise being compared to null which will false.

Fixes the logic via a cast to boolean on the document result.
  • Loading branch information
meschbach committed Mar 9, 2020
1 parent 9aec46c commit 7c3fbc5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions couchdb.js
Expand Up @@ -137,8 +137,8 @@ class Database {
* @return true if the document exists, otherwise false
*/
async exists( id ){
const document = this.maybe_by_id(id);
return null == document;
const document = await this.maybe_by_id(id);
return !!document;
}
}

Expand Down

0 comments on commit 7c3fbc5

Please sign in to comment.