$trunc

Update records by setting the value of a numeric column to its truncated value, removing any digits after the decimal point without rounding. The $trunc method is used to cut off the fractional part of the number, effectively performing a “floor” operation for positive numbers and a “ceiling” operation for negative numbers. For example, if the column value is 3.8, it will be truncated to 3, and if the value is -3.8, it will be truncated to -3. This is useful when you need to discard the fractional part without rounding the number.

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

Last updated