awaited .find()
method returns an empty array which is truthy in JavaScript, try:
console.log(![])
You can use .findOne()
instead and in that case null
will be returned when there's no match and your condition will work
awaited .find()
method returns an empty array which is truthy in JavaScript, try:
console.log(![])
You can use .findOne()
instead and in that case null
will be returned when there's no match and your condition will work