{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"redocly_category":"Integrations","type":"markdown"},"seo":{"title":"MongoDB Collections Export Integration","description":"Export MongoDB collections from Treasure AI jobs with ease, enabling data scientists to streamline metrics tracking, top N calculations, and dashboard visualizations.","siteUrl":"https://docs.treasure.ai","lang":"en-US","jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.treasure.ai/","name":"Treasure AI","url":"https://www.treasure.ai/","logo":"https://www.treasure.ai/hubfs/assets/images/logos/primary-logo.svg"},{"@type":"WebSite","@id":"https://docs.treasure.ai/#website","name":"Treasure AI Documentation","url":"https://docs.treasure.ai/","inLanguage":["en","ja"],"publisher":{"@id":"https://www.treasure.ai/"}}]},"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"mongodb-collections-export-integration","__idx":0},"children":["MongoDB Collections Export Integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This integration allows you to export TD job results into your existing MongoDB instance. For sample workflows on this, please view ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/treasure-boxes/tree/master/td/mongodb"},"children":["Treasure Boxes"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Basic knowledge of Treasure Data, including the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://toolbelt.treasuredata.com/"},"children":["TD Toolbelt"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["A MongoDB instance"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Data must have the proper privileges."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"reference-architecture","__idx":2},"children":["Reference Architecture"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A front-end application collects data into Treasure Data via the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/about-treasure-data-s-server-side-agent"},"children":["Treasure Agent"]},". Treasure Data periodically runs jobs on the data, then writes the job results to your MongoDB collections."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-1-ranking-what-are-the-top-n-of-x","__idx":3},"children":["Example 1: Ranking: What are the “Top N of X?”"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every social/mobile application calculates the “top N of X” (e.g., top 5 movies watched today). Treasure Data already handles the raw data warehousing; the “write-to-mongodb” feature also enables Treasure Data to find the “top N” data."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-2-dashboard-application","__idx":4},"children":["Example 2: Dashboard Application"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you are a data scientist, you need to keep track of a range of metrics every hour/day/month and make them accessible via visualizations. Using this “write-to-mongodb” feature, you can streamline the process and focus on your queries and visualizations of the query results."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"static-ip-address-of-treasure-data-integration","__idx":5},"children":["Static IP Address of Treasure Data Integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Please find the complete list of static IP addresses, organized by region, at the following ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/endpoints/ip-addresses-integrations-result-workers"},"children":["document"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"define-your-query","__idx":6},"children":["Define your Query"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Data Workbench > Queries"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["New Query"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Run the query to validate the result set."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image_query.00de4ab95ede0f38aead6d0dc65b242f4a9d5bb2bcb5ba65df3aa62e2227d1a0.39469d06.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":4},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Output Results"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191020-191715.040a6bfd0ad20a5ceaad2ce2b30d18b947abd48dc6c00f37816c0341a6d4139b.39469d06.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":5},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You can select an existing authentication or create a new authentication for the external service to be used for output. Choose one of the following:"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use Existing Integration"]}," ",{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191020-191821.37c8e5a38af942b34ae1f23ad8d63dc6d585251e4d6b4fa514b0f056a83d1134.39469d06.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create a New Integration"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/mongo-output.47191c1dcb7d82ab838cac7870a51056050e277170bdcc5f5a334deada12a027.39469d06.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Specify information for Export to MongoDB."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191020-191857.1cce93bdfb65864d1017a6a2f2676efb1fb0dde031bcac045e14e3eee58d5016.39469d06.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field Name"},"children":["Field Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Host"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The hostname or IP address of the remote server. (You can add more than one IP address, depending on your MongoDB setup.)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Username"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Username to connect to the remote database."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Password"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Password to connect to the remote database."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Use TLS?"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check this box to connect using TLS (SSL)."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bypass certificate validations?"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check this box to bypass all certificate validations."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Use Service records?"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Enable if you create a cluster on MongoDB cloud. Only the first host in hosts is used and the value must be a cluster name (e.g. ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://cluster0.be2g8go.mongodb.net/"},"children":["cluster0.be2g8go.mongodb.net"]},") when enabling."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Database name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The name of the database to which you are transferring data (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["your_database_name"]},")."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Table Name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The name of the collection to which you are transferring data."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Mode"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Append - Add to the existing records in the database. This mode is atomic.  Replace - Replace the existing records with the query results. This mode is atomic.  Truncate - Truncate the existing records. This mode is atomic.  Update - a row is inserted unless it can cause a duplicate value in the columns specified in the “keys” parameter"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"create-an-activation-using-an-integration","__idx":7},"children":["Create an Activation Using an Integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can create an activation to export segment data or stages."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you need to create an activation for a batch journey, review ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/journey-orchestration/batch/creating-a-batch-journey-activation"},"children":["Creating a Batch Journey Activation"]},"."]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Navigate to Audience Studio."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select a segment."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create Activation"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["See Also"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/int/using-the-cli-to-output-query-results"},"children":["Using the CLI to Output Query Results"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"integration-parameters-for-mongodb","__idx":8},"children":["Integration Parameters for MongoDB"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image_activation_mongo.d0252a5ac0bcb2477c67225f30e0e7d8d0ea68674e1044e39212315ba68de1d8.39469d06.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field Name"},"children":["Field Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Database name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The name of the database to which you are transferring data (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["your_database_name"]},")."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Table Name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The name of the collection to which you are transferring data."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Mode"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Append - Add to the existing records in the database. This mode is atomic.  Replace - Replace the existing records with the query results. This mode is atomic.  Truncate - Truncate the existing records. This mode is atomic.  Update - a row is inserted unless it can cause a duplicate value in the columns specified in the “keys” parameter"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Keys"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Comma-separated list of keys. If the values for all keys match an existing record, that record will be replaced."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-of-a-query","__idx":9},"children":["Example of a Query"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT * FROM my_table\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"optional-schedule-query-export-jobs","__idx":10},"children":["(Optional) Schedule Query Export Jobs"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data's scheduler feature supports periodic query execution to achieve high availability."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, if the cron schedule is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'0 0 1 * 1'"]},", then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"scheduling-your-job-using-treasure-console","__idx":11},"children":["Scheduling your Job Using Treasure Console"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Data Workbench > Queries"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create a new query or select an existing query."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Next to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Schedule"]},", select None."," ",{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png","alt":""},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In the drop-down, select one of the following schedule options:"," ",{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Drop-down Value"},"children":["Drop-down Value"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Custom cron..."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Review ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#custom-cron-details"},"children":["Custom cron... details"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["@daily (midnight)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Run once a day at midnight (00:00 am) in the specified time zone."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["@hourly (:00)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Run every hour at 00 minutes."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["No schedule."]}]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"custom-cron-details","__idx":12},"children":["Custom cron... Details"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Cron Value"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Cron Value"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Description"]}]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0 * * * *"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Run once an hour."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0 0 * * *"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Run once a day at midnight."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0 0 1 * *"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Run once a month at midnight on the morning of the first day of the month."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["\"\""]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Create a job that has no scheduled run time."]}]}]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":" *    *    *    *    *\n -    -    -    -    -\n |    |    |    |    |\n |    |    |    |    +----- day of week (0 - 6) (Sunday=0)\n |    |    |    +---------- month (1 - 12)\n |    |    +--------------- day of month (1 - 31)\n |    +-------------------- hour (0 - 23)\n +------------------------- min (0 - 59)\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following named entries can be used:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Day of Week: sun, mon, tue, wed, thu, fri, sat."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A single space is required between each field. The values for each field can be composed of:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"fixed-table"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"35%","data-label":"Field Value"},"children":["Field Value "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"20%","data-label":"Example"},"children":["Example "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"45%","data-label":"Example Description"},"children":["Example Description "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A single value, within the limits displayed above for each field."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A wildcard ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'*'"]}," to indicate no restriction based on the field."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'0 0 1 * *'"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Configures the schedule to run at midnight (00:00) on the first day of each month."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A range ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'2-5'"]},", indicating the range of accepted values for the field."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'0 0 1-10 * *'"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Configures the schedule to run at midnight (00:00) on the first 10 days of each month."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A list of comma-separated values ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'2,3,4,5'"]},", indicating the list of accepted values for the field."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'0 0 1,11,21 * *'"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A periodicity indicator ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'*/5'"]}," to express how often based on the field's valid range of values a schedule is allowed to run."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'30 */2 1 * *'"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'0 0 */5 * *'"]}," configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A comma-separated list of any of the above except the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'*'"]}," wildcard is also supported ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'2,*/5,8-10'"]},"."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'0 0 5,*/10,25 * *'"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month."]}]}]}]}]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["(Optional) You can delay the start time of a query by enabling the Delay execution."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"execute-the-query","__idx":13},"children":["Execute the Query"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["(Optional) You can delay the start time of a query by enabling the Delay execution."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"optionally-configure-export-results-in-workflow","__idx":14},"children":["Optionally Configure Export Results in Workflow"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Within Treasure Workflow, you can specify the use of this data connector to export data."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Learn more at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/tools/cli-and-sdks/api#workflow-commands"},"children":["Using Workflows to Export Data with the TD Toolbelt"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-workflow-for-mongodb","__idx":15},"children":["Example Workflow for MongoDB"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"#Example Workflow\n_export:\n  result_connector_name: mongodb_connector\n  target_database_name: mongodb_database\n  target_collection_name: mongodb_collection\n\n+export_to_mongodb:\n  td>: your_query.sql\n  result_connection: ${result_connector_name}\n  result_settings:\n    database: ${target_database_name}\n    table: ${target_collection_name}\n    mode: [append|replace|truncate|update]\n","lang":"yaml"},"children":[]}]},"headings":[{"value":"MongoDB Collections Export Integration","id":"mongodb-collections-export-integration","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Reference Architecture","id":"reference-architecture","depth":2},{"value":"Example 1: Ranking: What are the “Top N of X?”","id":"example-1-ranking-what-are-the-top-n-of-x","depth":3},{"value":"Example 2: Dashboard Application","id":"example-2-dashboard-application","depth":3},{"value":"Static IP Address of Treasure Data Integration","id":"static-ip-address-of-treasure-data-integration","depth":2},{"value":"Define your Query","id":"define-your-query","depth":2},{"value":"Create an Activation Using an Integration","id":"create-an-activation-using-an-integration","depth":2},{"value":"Integration Parameters for MongoDB","id":"integration-parameters-for-mongodb","depth":1},{"value":"Example of a Query","id":"example-of-a-query","depth":2},{"value":"(Optional) Schedule Query Export Jobs","id":"optional-schedule-query-export-jobs","depth":3},{"value":"Scheduling your Job Using Treasure Console","id":"scheduling-your-job-using-treasure-console","depth":4},{"value":"Custom cron... Details","id":"custom-cron-details","depth":4},{"value":"Execute the Query","id":"execute-the-query","depth":3},{"value":"Optionally Configure Export Results in Workflow","id":"optionally-configure-export-results-in-workflow","depth":2},{"value":"Example Workflow for MongoDB","id":"example-workflow-for-mongodb","depth":3}],"frontmatter":{"seo":{"title":"MongoDB Collections Export Integration","description":"Export MongoDB collections from Treasure AI jobs with ease, enabling data scientists to streamline metrics tracking, top N calculations, and dashboard visualizations."}},"lastModified":"2026-06-17T07:22:53.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/int/mongodb-collections-export-integration","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}