I’m about to set up the functionality for adding contacts, and I need to decide between these three options:
A) I’m guessing the most basic way would be to have a Contacts collection, with the same ids as the users, then store an array for everyone that the user is contacts with.
To check, I’d get the array and see if it includes the id.
B) Creating compound indexes (except the order of the two indexes matter, so it I’d have to set it up for both users. also, it requires the memory of the collection + the indexing).
C) Create a collection ContactPairs, with ids having this format “idA_idB” (they are sorted alphabetically before being created/queried), and they can store information like a Date “contactsSince”.
C would be efficient because it uses ids and it would take less space than B. Though it would have to be complemented by A.
What do you think?