You can insert a property with null value.
Example
db.employee.insert({"firstName" : "Krishna", "lastName" : "Gurram", "hobbies" : null}) db.employee.insert({"firstName" : "Thulasi", "lastName" : null, "hobbies" : ["playing tennis", "singing"]})
> db.employee.insert({"firstName" : "Krishna", "lastName" : "Gurram", "hobbies" : null}) WriteResult({ "nInserted" : 1 }) > > db.employee.insert({"firstName" : "Thulasi", "lastName" : null, "hobbies" : ["playing tennis", "singing"]}) WriteResult({ "nInserted" : 1 }) > > > db.employee.find().pretty() { "_id" : ObjectId("60bdc1488251689f64fb3ef3"), "firstName" : "Krishna", "lastName" : "Gurram", "hobbies" : null } { "_id" : ObjectId("60bdc16e8251689f64fb3ef4"), "firstName" : "Thulasi", "lastName" : null, "hobbies" : [ "playing tennis", "singing" ] }
No comments:
Post a Comment