I am developing a REST web service with a Parent, Child many-to-many relationship.
If I have an existing Parent with a relationship collection of Child objects and as an example: Existing Parent 1 has children associations Child 1 (id=1), Child 2(id=2) And I receive an Update call to the web service for Parent 1 to set the children to [2,3] that is it should now only have Child 2 and Child 3 and the existing relation to Child 1 should be removed. What is the best practice for doing that. Currently I can picture: 1. Load Parent 1 2. Loop over p1.children and find all existing children ids that are not in the new [2,3] collection and issue a p1.children.remove(existing_child) 3. then loop over the new id array and for each one in here that is not in the existing child collection load that child object (C3 in this case) from the db and do p1.children.add(C3) Is there any api that can shorten this procedure? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.