For an futur project I need to count children of an object.
I have an object A with children of type B and C. I would count the child number on type B and C, I see 3 methods
method 1 : use a views
method 2 : add a values in object A to store children number. But I need to update the A with CAS method (to ensure database consistency ) when I add/remove an child.
method 3 : add a new document (one by child type) to save number and use atomic method incr and decr when I add/remove an child. But with this method like all key must be in RAM, I need more memory on server.
What is the best approach for my problem ? 1, 2, 3 or other ?