Compare 2 fields in arrayFilters


I would like to compare two fields inside the arrayFilters. In particulare, I have the following modeling:

services: [
    name: string
    total: number
    current: number

I would like to perform the following operation:

let delta: number = 1
let serviceName: string = "serviceName"
let filterOp = {
   _id: ObjectId("...")
let updateOp = {
  $inc: {
       "services.$[service].current": delta
let arrayFiltersOp = [
   "": serviceName //This is just to filter by serviceName and it works.
   "": {$gte: "$service.current" + delta} //This doesn't work!!!


Hi @Matteo_Tarantino ,

Yes I don’t think that with array filter you will be able to compare a calculated value from another field.

You will have to perform an aggregation pipeline update and use $map to traverse arrays and calculate fields:,of%20another%20field(s).

If you have troubles writing a specific one let me know