preserve null and empty arrays mongodb code example
Example 1: mongodb empty an array field
db.collection.update({}, { $set : {'myArray': [] }} , {multi:true} )
Example 2: mongodb unwind
{
$unwind:
{
path: <field path>,
includeArrayIndex: <string>,
// to include documents whose sizes field is null, missing, or an empty array.
preserveNullAndEmptyArrays: <boolean>
}
}