Field Path
noun
say it: “FEELD PATH” /ˈfild ˈpæθ/
In a MongoDB pipeline, a field name written with a dollar sign in front, such as "$total", meaning that field's value in each document.
What is a field path in an aggregation pipeline?
A field path is a field name in quotes with a $ in front, such as "$total", and it means "this document's value of that field". Inside a pipeline it's how a stage reads a field, where "total" without the $ is plain text.
db.orders.aggregate([
{ $group: { _id: "$category", revenue: { $sum: "$total" } } }
]);
// "$category" and "$total" read each order's own values
In a sentence
- “Writing "total" instead of the field path "$total" made $sum add up zeros.”
- “The field path "$customer.city" reads the city inside each order's customer document.”
Level: Journeyman · More MongoDB terms at this level
Updated