The normal way of doing tagging seems to be indexing multikeys. Even if your MongoDB driver doesn’t implement distinct, we can implement.
In JavaScript you can write something like this:
1
result = db.$cmd.findOne({“distinct” : “collection_name”, “key” : “tags”})
You do a findOne on the “$cmd” collection of whatever database you’re using. Pass it the collection name and the key you want to run distinct on.
If you ever need a command your driver doesn’t provide a helper for, you can look at the below link for complete list of database commands.
https://docs.mongodb.com/manual/reference/command/