I have a priceGroup collection.

```
  {
    "_id" : ObjectId("5e67dc3bbf237bb991f677be"),
    "productType" : {
        "_id" : ObjectId("5e67cddc5150bf069b000ab0"),
        "name" : "ERW Pipes",
        "code" : "03"
    },
    "grade" : {
        "_id" : ObjectId("5e67cddc5150bf069b000abd"),
        "name" : "MS",
        "code" : "01"
    },
    "make" : {
        "_id" : ObjectId("5e67861d2df8eac1fa614e8b"),
        "name" : "Primary",
        "code" : "01"
    },
    "attributeGroupType" : "classification",
    "attributeGroupValue" : "LIGHT",
    "prices" : [ 
        {
            "_id" : ObjectId("5e67e4401a484e0d3a89f316"),
            "region" : {
                "_id" : ObjectId("5e67b1f972419a86996b26fe"),
                "name" : "Bhilai",
                "code" : "BH"
            },
            "price": 1200
            "isAutocalculated" : false
        }, 
        {
            "_id" : ObjectId("5e67e4401a484e0d3a89f317"),
            "region" : {
                "_id" : ObjectId("5e67b1f972419a86996b26ff"),
                "name" : "Pune",
                "code" : "PU"
            },
            "lastPrice" : 1230,
            "price" : 1245
            "isAutocalculated" : true
        }
    ],
    "createdAt" : ISODate("2020-03-10T18:28:11.831Z"),
    "updatedAt" : ISODate("2020-03-10T19:02:24.150Z"),
    "__v" : 0
} 

```

I want to update the prices of a given doc for all regions.
I am updating the prices like this

```
 db.priceGroups.updateOne(
            {
                'productType.name': 'ERW Pipes',
                'grade.name': 'MS',
                'make.name': 'Primary',
                attributeGroupValue: 'LIGHT'
            },
            {
                prices: [
    {
        region: {
            _id: '5e67b1f972419a86996b26fe',
            name: 'Bhilai',
            code: 'BH',
            __v: 0
        },
        price: '1230',
        isAutocalculated: false
    },
    {
        region: {
            _id: '5e67b1f972419a86996b26fe',
            name: 'Pune',
            code: 'PU',
            __v: 0
        },
        price: '1260',
        isAutocalculated: false
    }
]
            }
        );

```

**I want to add/update a field lastPrice with each element of prices array. lastPrice is the price of the item before it was updated. I understand I can first do a findOne and add a lastPrice to the update object and then call updateOne. But is there any way that this could be done using just single query?**

After update the desired result is

```
  {
    "_id" : ObjectId("5e67dc3bbf237bb991f677be"),
    "productType" : {
        "_id" : ObjectId("5e67cddc5150bf069b000ab0"),
        "name" : "ERW Pipes",
        "code" : "03"
    },
    "grade" : {
        "_id" : ObjectId("5e67cddc5150bf069b000abd"),
        "name" : "MS",
        "code" : "01"
    },
    "make" : {
        "_id" : ObjectId("5e67861d2df8eac1fa614e8b"),
        "name" : "Primary",
        "code" : "01"
    },
    "attributeGroupType" : "classification",
    "attributeGroupValue" : "LIGHT",
    "prices" : [ 
        {
            "_id" : ObjectId("5e67e4401a484e0d3a89f316"),
            "region" : {
                "_id" : ObjectId("5e67b1f972419a86996b26fe"),
                "name" : "Bhilai",
                "code" : "BH"
            },
            "price" : 1230,
            "lastPrice" : 1200,
            "isAutocalculated" : false
        }, 
        {
            "_id" : ObjectId("5e67e4401a484e0d3a89f317"),
            "region" : {
                "_id" : ObjectId("5e67b1f972419a86996b26ff"),
                "name" : "Pune",
                "code" : "PU"
            },
            "price" : 1260,
            "lastPrice" : 1245,
            "isAutocalculated" : true
        }
    ],
    "createdAt" : ISODate("2020-03-10T18:28:11.831Z"),
    "updatedAt" : ISODate("2020-03-10T19:02:24.150Z"),
    "__v" : 0
} 

```

Desired output explanation
==========================

The first entry in price didn't have a lastPrice so after update price value was set to a newly appended 'lastPrice' key and price was updated with the new incoming price. 
The second entry already had a lastPrice so after update price value was set to lastPrice and price was updated with the new one.