How can I remove all fields that are null from all documents of a given collection?
null
I have a collection of documents such as:
{
You can use the mongo updateMany functionality, but you must do this by specifying the parameter you are going to update, such as the year parameter:
year
db.collection.updateMany({year: null}, { $unset : { year : 1 }})