$replace

Update records by replacing a specified portion of the column’s value with a new value. The $replace method is used to modify part of an existing value, typically for strings or text columns, where the specified substring is replaced with the new provided value.

await Member.$update({
    $where: { 
        age: { 
            $eq: 16 
        } 
    },
    $update: {
        $replace: {
            username: { 
                $searchValue: 'four',
                $replaceValue: 'five'
            }
        }
    }
});

Last updated