$mod

Update records by setting the value of a numeric column to the result of a modulo operation. The $mod method is used to calculate the remainder when a number is divided by another number. For example, if the column value is 10 and the divisor is 3, the result will be 1 (since 10 รท 3 leaves a remainder of 1). This operation is useful for situations where you need to work with remainders, such as when determining if a value is divisible by another number or handling cyclic data.

await Member.$update({
    $where: { 
        age: { 
            $eq: 16 
        } 
    },
    $update: {
        $mod: {
          age: 2
        }
    }
});

Last updated