I have an array element in my DB and I want to group By and calculate the number of repetitions of different elements in this array. assume following collection:
{
_id: ObjectId(7df78ad8902c)
title: 'MongoDB Overview',
tags: ['SQL', 'database', 'NoSQL'],
},
{
_id: ObjectId(7df78ad8902d)
title: 'NoSQL Overview',
tags: ['mongodb', 'database', 'PHP'],
}
I want to calculate the number of repetitions of different elements in tags field such as mongodb, database, noSQL in this collection. How can I solve this problem in mongo?