$updateMany

Update multiple records in the table based on the provided conditions. The $updateMany method is used to modify specific fields of all records that match the given conditions, making it ideal for batch updates.

Query
Parameter's

$where

<StaticProps>

$update

$rules

$options

<FindOptions>

var updatedMembers = await Member.$updateMany({
    $where: {
        isPremium: true,
        displayName: {
            $endsWith: '5'
        }
    },
    $update: {
        $lowercase: {
            username: true,
        }
    },
    $rules: {
        username: {
            $alphaNumeric: true
        }
    },
    $options: {
        $upsert: true,
        $cache: { $key: 'members', $ttl: 30_000 }
    }
});

Last updated