Reader small image

You're reading from  Practical MongoDB Aggregations

Product typeBook
Published inMar 2024
PublisherPackt
ISBN-139781835884362
Edition1st Edition
Tools
Right arrow
Author (1)
Paul Done
Paul Done
author image
Paul Done

Paul Done is a Field CTO at MongoDB Inc., having been a Solutions Architect for the past decade at MongoDB. He has previously held roles in various software disciplines, including engineering, consulting, and pre-sales, at companies like Oracle, Novell, and BEA Systems. Paul specializes in databases and middleware, focusing on resiliency, scalability, transactions, event processing, and applying evolvable data model approaches. He spent most of the early 2000s building Java EE (J2EE) transactional systems on WebLogic, integrated with relational databases like Oracle RAC and messaging systems like MQ Series.
Read more about Paul Done

Right arrow

What do expressions produce?

An expression can be an operator (e.g., {$concat: ...}), a variable (e.g., "$$ROOT"), or a field path (e.g., "$address"). In all these cases, an expression is just something that dynamically populates and returns a new element, which can be one of the following types:

  • Number (including integer, long, float, double, and decimal128)
  • String (UTF-8)
  • Boolean
  • DateTime (UTC)
  • Array
  • Object

However, a specific expression can restrict you to returning just one or a few of these types. For example, the {$concat: ...} operator, which combines multiple strings, can only produce a string data type (or null). The "$$ROOT" variable can only return an object that refers to the root document currently being processed in the pipeline stage.

A field path (e.g., "$address") is different and can return an element of any data type, depending on what the field refers to in the current input document....

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical MongoDB Aggregations
Published in: Mar 2024Publisher: PacktISBN-13: 9781835884362

Author (1)

author image
Paul Done

Paul Done is a Field CTO at MongoDB Inc., having been a Solutions Architect for the past decade at MongoDB. He has previously held roles in various software disciplines, including engineering, consulting, and pre-sales, at companies like Oracle, Novell, and BEA Systems. Paul specializes in databases and middleware, focusing on resiliency, scalability, transactions, event processing, and applying evolvable data model approaches. He spent most of the early 2000s building Java EE (J2EE) transactional systems on WebLogic, integrated with relational databases like Oracle RAC and messaging systems like MQ Series.
Read more about Paul Done