$toFixed

Update records by setting the value of a numeric column to a fixed-point number with a specified number of decimal places. The $toFixed method is used to format a numeric value by rounding it to a defined number of decimal places, ensuring consistency in the display or storage of numbers. For example, if the column value is 3.14159 and you use $toFixed: 2, it will be rounded to 3.14. This is useful for financial data, measurements, or any situation where precision is needed.

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

Last updated