MongoDB: Should I use an aggregation pipeline or maintain a field count for reference counts? #8
Unanswered
Sunny-unik
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on a MongoDB application with two collections, A and B. In collection A, there are multiple documents that contain a field referencing the ID of a document in collection B.
I want to calculate and store a count of how many documents in collection A reference each document in collection B. I have considered two approaches:
countOfA
field in collection B:I'm having trouble deciding which approach to use. Which one would be the best practice and more suitable for production use? Are there any potential pitfalls or additional considerations I should be aware of for each approach?
Beta Was this translation helpful? Give feedback.
All reactions