# $set and $addFields

*noun*

say it: **“DOL-er SET and DOL-er ad-FEELDZ”** **/ˈdɑlər ˈsɛt ənd ˈdɑlər ˌædˈfildz/**

Two names for one MongoDB aggregation stage that adds a calculated field to each document while keeping the rest.

## What does the **$set** (or **$addFields**) stage do?

**$set** and **$addFields** are two names for the same aggregation stage: it adds a field worked out for each document, or replaces one with the same name, and keeps every other field. (In an update, `$set` is the update operator instead.)

```javascript
db.orders.aggregate([
  { $set: { totalWithTax: { $multiply: ["$total", 1.07] } } }
]);
// each order with all its fields, plus totalWithTax
```

## In a sentence

- “A **$set and $addFields** stage put a lineTotal on every order item.”
- “Unlike $project, **$set and $addFields** keep every field the document already had.”

Level: Journeyman · [More MongoDB terms at this level](https://www.ask-codey.com/glossary?category=mongodb&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/set-and-addfields
