$concat

The $concat operation is used to merge multiple strings or arrays into a single string or array. When applied to strings, it joins them together without any separators. When used with arrays, it combines their elements into a single array while preserving the order. This operation is useful for dynamically constructing text values, merging lists of data, or appending new elements to an existing collection efficiently.

await Member.$update({
    $where: { 
        age: { 
            $eq: 16 
        } 
    },
    $update: {
       $concat: {
         badges: ['MODERATOR']
       }
    }
});

Last updated