I am making a Boolean entry
through the mongoose schema
. The parameters are : username,password and admin
.
The admin parameter is set as boolean and default value as "true". Now while making an entry through post request, if I skip making the admin field, then its value gets stored as true
.
But if I explicitly mention it as false
, then the value is not stored in the database
.
Why is this happening?
A javascript boolean can only either be true, or false. If it isn't true then it must be false. So any boolean field stored in the database without a value must be false (since it isn't true).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.