$pop

Remove an element from an array field in the specified column. The $pop method removes either the last element ($pop: 1 | true) or the first element ($pop: -1 | false) from an existing array.

• $pop: 1 → Removes the last element of the array.

• $pop: -1 → Removes the first element of the array.

For example, if the current value of a column is ["apple", "banana", "cherry"]:

• $pop: 1 → Result: ["apple", "banana"]

• $pop: -1 → Result: ["banana", "cherry"]

This is useful for modifying array-based data dynamically.

await Member.$update({
    $where: { 
        age: { 
            $eq: 16 
        } 
    },
    $update: {
        $pop: {
            badges: -1
        }
    }
});

Last updated