Docs Menu

Docs HomeMongoDB Atlas

$out

On this page

  • Permissions Required
  • Syntax
  • Fields
  • Options
  • Examples
  • Simple String Example
  • Single Field from Documents
  • Multiple Fields from Documents
  • Multiple Types of Fields from Documents
  • Write to Collection on Atlas Cluster
  • Run Query in the background
  • Limitations
  • String Data Type
  • CSV and TSV File Format
  • Parquet File Format

$out takes documents returned by the aggregation pipeline and writes them to a specified collection. The $out operator must be the last stage in the aggregation pipeline. In Atlas Data Federation, you can use $out to write data from any one of the supported federated database instance stores or multiple supported federated database instance stores when using federated queries to any one of the following:

  • S3 buckets with read and write permissions

  • Atlas cluster namespace

You must connect to your federated database instance to use $out.

Option
Type
Description
Necessity
background
boolean

Flag to run aggregation operations in the background. If omitted, defaults to false. When set to true, Atlas Data Federation runs the queries in the background.

{ "background" : true }

Use this option if you want to submit other new queries without waiting for currently running queries to complete or disconnect your federated database instance connection while the queries continue to run in the background.

Optional

The following example shows $out syntax for running an aggregation pipeline that ends with the $out stage in the background.

Tip

See also:

←  $mergeRetrieve Federated Database Instance Query History →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.