$toPrecision
Update records by setting the value of a numeric column to a number with a specified total number of significant digits. The $toPrecision method is used to round the value to the specified precision, ensuring a consistent number of significant figures. For example, if the column value is 123.456 and you use $toPrecision: 4, it will be rounded to 123.5. This is useful when you want to maintain a specific level of precision in your data, such as for measurements or scientific calculations.
await Member.$update({
$where: {
age: {
$eq: 16
}
},
$update: {
$toPrecision: {
age: 4
}
}
});
Last updated