Open Granitosaurus opened 4 years ago
Hi @Granitosaurus, usually in cases like this, I like to ask for the intended output. But thanks to your fairly thorough illustration, I assume the intention here is a multi-delete?
If so, then I should mention (and maybe update the docs to say) that glom's deep mutation spec types (both Assign and Delete) are only for single mutations at this time. PRs certainly considered, though mutation can be tricky.
Technically calling it in a loop might work, but have you tried glom.glom(foo, (items, [Delete('foo')])
?
@mahmoud very interesting, your suggestion does work! But it's a bit awkward to use:
>>> glom.glom(foo, ("items", [glom.Delete('foo')]))
[{'bar': '2'}, {'bar': '2'}, {'bar': '2'}]
I think coming up to this usage as glom user would be very difficult but it works! I think it's worth documenting that and whole delete function as I think it can be a killer feature of glom!
Anyway for my use case this is good enough, thanks!
possibly we could extend delete to support slices? definitely kind of tricky
oh I misunderstood, this is talking about multiple parallel deletes -- not deleting multiple items from the same list
probably *
-paths will help with this :-)
when trying to delete path with square brackets like
('products', ['id'])
glom throws:example: