Answer the question
In order to leave comments, you need to log in
How to remove null and empty element in MongoDB?
I'm trying to remove the null value and the empty { } element in reviews:
"reviews" : [
{
"author" : "Simon Holmes",
"id" : ObjectId("57acdb16cec290c7a1466cf4"),
"rating" : 5,
"timestamp" : ISODate("2015-07-15T23:00:00Z"),
"reviewText" : "What a great place. I can't say enough good things about it.",
"_id" : ObjectId("57b6116a9d4d1e8bc7067387")
},
null,
{
}
]
db.locations.update( {"name" : "Starcups 2"}, {$unset: { "reviews.1.null": "" } } );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question