Perform multiple updates (upserts) on Embedded documents

you can wrap the query inside a function,and use the dynamic arguments,if this is what you ask.
we can use update operators also to do the updates and not pipeline updates,but here pipeline is used,pipeline ones are more powerful but takes some time to learn the pipelines operators.