Given a tree of objects in Drive Realtime API with a concurrent operation in two or more clients where existing children are moved into a new parent (think of a grouping operation in a graphical editor), what is the best datastructure to avoid a) duplicate existing children and b) empty new parents?

有帮助吗?

解决方案

Can each child only have a single parent?

If that is the case, I would suggest having a "parent" field on the child objects. This guarantees that each child only has one parent, and the non-empty parent set is implicitly created by looking finding all the parents.

You could easily maintain this parent set by doing a one-time scan through the children on startup, and then listening for change events on the child and updating the set accordingly.1111

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top