MongoDB $pullAll Operator (original) (raw)

Last Updated : 15 Apr, 2026

The $pullAll operator in MongoDB removes all occurrences of specified values from an array field during updates, offering a direct way to clean array data without using query conditions.

Syntax

{ $pullAll: { : [ , ... ], ... } }

**Note: The $pullAll operator removes all matching values from the array; the order of removal is not relevant as it is value-based.

Examples of MongoDB $pullAll

We will use the contributor collection for the following examples:

Screenshot-2026-02-13-173359

Example 1: Removing items from an array

Remove the items ["Java", "C#", "Python"] from the language field for the contributor "Liam" using the $pullAll operator.

db.contributor.updateOne(
{ name: "Liam" },
{ $pullAll: { language: ["Java", "C#", "Python"] } }
)

**Output:

Screenshot-2026-02-13-173704

Example 2: Removing items from an array in the embedded document

Remove the items [71, 72] from the personal.semesterMarks field for the contributor "Noah" using the $pullAll operator.

db.contributor.updateOne(
{ name: "Noah" },
{ $pullAll: { "personal.semesterMarks": [71, 72] } }
)

**Output:

Screenshot-2026-02-13-173934