Simple, self-explanatory code snippets.
db.COLLECTION_NAME.aggregate([
{$addFields: {
'SUB_DOCUMENT_FIELD_COUNT':
{$size:
{$objectToArray:
{$ifNull: [
"$YOUR_FIELD",
{}
]}
}
},
}},
]);
No comments:
Post a Comment