Updating element in array in mongo db with an element from a different array

0
down vote
favorite
Can’t seem to figure out the proper way of doing this.

So I have a


        { "_id" : "Btn7GTdaEy9umzXjF", 
     "orders" : [ 
    {  "productId" : "Btn7GTdaEy9umzXjF", "ownerId" : "7EdwL4c4wZd746BLZ" }, 
    { "productId" : "Btn7GTdaEy9umzXjF", "ownerId" : "7EdwL4c4wZd746BLZ" } 
    ], "orderCount" : 12, "fulfillments" : [
 {"ownerId":"",data:{could be any valid json}},
{"ownerId":"",data:{could be any valid json}}
] }

What I need to do is transfer the ownerId from the orders column and insert it into the ownerId field in the fulfillments column. Although I need to do this for every product for a particular user at once.

Right now I am running a query like this to find all the orders for a particular user where there is no fulfillment id for that user, but the user is in the orders field.

var productsOrderedNotFulfilled = Products.find({
      downloads:[],
      "fulfillments.ownerId":{
              $ne:this.userId},
      orders:{$elemMatch:{ownerId:this.userId}}},
      {fields:{_id:1}});

And then I am iterating over all the ids and finding a fulfillment where the ownerId is blank or “” and then inserting that owner id into the fulfillments array where that particular fulfillment is.

Is there a way to do this with pure mongo and not using vanilla javascript to do most of the work?