I have two collections: collection A
and collection B
. Collection B "A_id" will have the _id from Collection A (kinda like a relationship).
Collection A
{
_id,
name
}
Collection B
{
_id,
A_id,
other_id
}
I need to sort the documents from Collection A by the amount of repetitions of documents to an A_id in Collection B (sort by count if you may). The constraint is that we don't want to have an array in collection A because the documents in B will grow a lot and will be updated constantly.
Any idea how to perform this kind of sorting?
Thanks much