Pure front end, did not contact the background database before, now study mongodb database, encounter such a situation, set up a blog database, there is such a collection containing all the article information, the data forgery is as follows:
{ "id" : 1, "name" : "one", "tags" : [ "a", "c", "e" ] }
{ "id" : 2, "name" : "two", "tags" : [ "e" ] }
{ "id" : 3, "name" : "three", "tags" : [ "d", "e" ] }
{ "id" : 4, "name" : "four", "tags" : [ "g", "c", "e", "h" ] }
{ "id" : 5, "name" : "five", "tags" : [ "a", "c", "d" ] }
tags indicates the tag type to which this article belongs. Now you want to find out how many different tag types there are and how many pieces of data are under each tag. How can this be realized? At present, the idea is to split the tags with $unwind in aggregate, and then group statistics with $group, but how to write the specific code, or there are other more effective ways, please let me know!