Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

mongodb node findone how to handle no results using promises

const assert = require('assert');

schema.static('findMinOne', function(conditions) {
  return this.find(conditions).then(res => assert.ok(res.length >= 1, 'No documents found'));
});
Source by github.com #
 
PREVIOUS NEXT
Tagged: #mongodb #node #findone #handle #results #promises
ADD COMMENT
Topic
Name
1+1 =