Docs Menu

Save and Reuse Queries

The Query Library allows you to reuse a query across multiple charts. If you save a query to the library, any user on your charts project can apply the same query on their own charts. Any changes to a query stored in the library impact all charts thar are connected to that query.

After you apply an aggregation pipeline query to a chart, you can save it to the Query Library. This makes the query available for use on other charts created by you and other users on the same charts project.

To save a query:

1

To learn more, see Run Aggregation Pipelines on Your Data and Filter Your Data Using the Query Bar.

2

The Query Library menu contains options for saving and loading queries.

3
4

The Query title field shows the names of each existing query and the number of charts that use the query. You can enter a new name for your query or select an eisting query name to overwrite the existing query with your new query.

If you enter a new name, you must also click Create <your-query-title> to create a named query in the library.

If you select an existing query from the list, the field is pre-populated with the selected query name. If you save an existing query, all charts connected to that query will inherit the new query text.

5

To use a previously saved query from the Query Library on a chart, use the Library dropdown to load the saved query. You can access queries saved by any user in the project.

To load saved queries:

1
2

The Query Library menu contains options for loading and saving queries.

3
4

By default, the current data source is selected. It contains the list of queries applied to charts using the current data source only.

You can choose Any data source to select from all saved queries in the library.

5

In the Load Query pane, the queries are listed in alphabetical order and are case insensitive. For each query, you can see the name of the query, the start of the query, and the number of charts that use the query. Also, you can do the following:

  • Hover over the tooltip icon to see the query owner and when the query was last modified.
  • Click x to close the library pane.

To learn more about all other actions that you can perform on the saved queries, see Manage Saved Queries.

6

After loading a query, you can run the query against the data in the chart. Also, you can modify or disconnect the query from the library. To learn more, see Modify or Disconnect Saved Queries.

After you load a saved query, you can modify or disconnect the query from the library.

To modify, make changes to the query in the query bar and save the query under its original name, only if you created the query or have the Project Owner role, or save the query under a new name.

If you save the modified query under the same name, all other charts using the same named query will inherit the modified query for reuse.

If you save the modified query in the library under a new name, the modified query, although unused by other charts initially, will be available for reuse in the future.

To disconnect, modify the query in the query bar and click Apply after changing the query. The query is disconnected from the library, which makes the modified query private to this chart. You must save the query to the library if you wish to reuse this query on other charts in the future. If you save the query under the same name in the library, all charts connected to it will inherit the new query.

Alternatively, click Revert before applying the query to the chart to undo the changes.

When you load a saved query, the query author or user with the Project Owner role can rename or delete the queries in the library.

1
2

The Query Library menu contains options for loading and saving queries.

3

In the Load Query pane, the queries are listed in alphabetical order and are case insensitive. You can do the following if you created the query or if you have the Project Owner role:

  1. Click the pencil icon next to the name of the query that you wish to rename.
  2. Enter the new name for the query. Each query name must be unique.
  3. Click the check mark to save the query under the new name.

    Rename or delete the query from the library.

  1. Click the trash icon for the query you wish to delete from the library.
  2. Choose one of the following options:

    • Delete the query from the library, and keep the contents of the query on the connected chart.

      If you choose this option, the query will continue to be available to any charts that used the query, but the query will be disconnected from the library and unavailable for any new charts.

    • Delete query from the library, and remove the contents of the query on the connected chart.

      If you choose this option, the query will be removed from the library and unavailable for any new or existing charts that used the query.

←  Run Aggregation Pipelines on Your DataFilter Chart Results →
Give Feedback
© 2022 MongoDB, Inc.

About

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