Hello @wan ,
Use cases are so many,everytime that you want to edit one embeded document
using a variable key (not literal, for example you didnt know it at pipeline writing time,you found it at pipeline run time) it is a use case.
Every programming language that has hash-maps provides those methods to process those
hash-maps.
Lets say you are in pipeline and you have this
$$mydoc = one document
$$mykey = one key
How to do
get("$$mydoc","$$mykey")
contains?("$$mydoc","$$mykey")
put("$$mydoc","$$mykey","randomValue")
remove("$$mydoc","$$mykey")
....
(and all those basic operation on maps that programming languages offer)
I managed to make so far only put,in a fast way using mergeObjects and objectToArray.
But it wasn’t straightforward at all.
For arrays its so easy to do a put it in mongoQL
{"$concatArrays" ["$$array1" ["$$newmember"]])}
I want something like the above but with embeded documents
If you want to see an use example see this post,where i tried to group an array
using reduce and i couldnt do it.
ObjectToArray and ArrayToObject are ok if document is small or if you will do it one time.
If you are in a reduce,i cant convert the object to array and back to object at each step.
Its like saying to a Javascript programmer,dont add to an Object make the object array first,add to array,and then back to Object,its too slow to be usable.
Thank you