I'm worried about this code:
knex('person').where('id','=', 1).then(result => {
const person = result[0]; // the code I worry - result should contain only ONE element
});
If I was using C#, I would use Linq's Single, it would fail fast and throw an exception if there are more than one element in result, say the where clause is forgotten or has wrong condition.
How would I implement that in JavaScript?