await Model.find(/*null or undefined*/) is returning the same as await Model.first()
So when one writes await Model.find(req.params.id) on Express with an empty id, it will inadvertently show or edit the wrong object.
Maybe it's best to return undefined, just like when finding by a primary key value absent from DB. Like if the query were select * from model where id is null limit 1.
await Model.find(/*null or undefined*/)
is returning the same asawait Model.first()
So when one writes
await Model.find(req.params.id)
on Express with an empty id, it will inadvertently show or edit the wrong object.Maybe it's best to return
undefined
, just like when finding by a primary key value absent from DB. Like if the query wereselect * from model where id is null limit 1
.