1const assert = require('assert');
2
3schema.static('findMinOne', function(conditions) {
4 return this.find(conditions).then(res => assert.ok(res.length >= 1, 'No documents found'));
5});
1const findUser = async function (params) {
2 try { return await User.findOne(params)
3 } catch(err) { console.log(err) }
4}
5
6const userSteve = findUser({firstName: Steve})