We currently have a collection of users where each document has, amongst other fields, an _id field and a _referrer field, which will be an _id of someone else in the user collection.
We want to be find every users a specific user referred to us, both directly or indirectly. So I want to be able to say Foo referred Bar who in turn referred Baz etc.
Given the size we anticipate (hope?) the collection will grow to just doing an aggregation on the spot is too slow, we need this precomputed.
I would like to create an index for this, but I'm not sure if indexes can support this use case. Is there a way to configure documentdb to generate this without our having to manually update a referrer's document whenever we add a new user?
Keep in mind were using documentDB, this has proved relevant as the original aggregation we were using in mongo failed when we moved everything into aws due to documentdb not supporting the aggregation stage.