Why is it that in mongoose (OR mongodb maybe) Boolean false
is not saved in the database but they are present in the result.
Mongoose schema:
fav : { type: Boolean, default: false }
Now if I mark it as true (via form input) , then only it is stored in the database otherwise it is not saved if it is 'undefined' (if not checked in form).
But if I fetch that field then it will output appropriate result as expected.
i.e if fav is true
then 'true' else false
.
The problem is that if I want to query for all the docs where fav
is false then I just get empty an array returned because when the value is false then that field (fav
) is not saved in the database,
But I can easily query for fav
==true because they are saved in the database.