I want to create a field like unordered_set (unique elements) in C++. I find 2 ways to do:
- list: tags = [“a”, “b”, “c”, …]
- embedded document: tags = {“a”: true, “b”: true, “c”: true, …}
At this time, I don’t care about indexes (multi-key indexes). I want to consider about these operations:
- Add a element into tags
- Find a element in tags
If tags is an array, searching is O(n).
If tags is an embedded document, does this way have better performance ??