Export Query to Specific Language将查询导出到特定语言¶
New in version 1.15.0
You can export queries created in the query bar to one of the supported languages; Java, Node, C#, and Python 3. 您可以将在查询栏中创建的查询导出到支持的语言之一:Java、Node、C#和Python 3。This feature facilitates reformatting and utilizing queries created in MongoDB Compass for use in your application.此功能有助于重新格式化和利用MongoDB Compass中创建的查询,以便在应用程序中使用。
Procedure过程¶
After constructing a query in the query bar, click to the right of the Reset button.在查询栏中构造查询后,单击“重置”按钮右侧的。Select Export to Language:选择“导出到语言”:click to enlarge-
In the Export Query To: dropdown, select your desired language:在“导出查询到:”下拉列表中,选择所需的语言:click to enlargeThe My Query pane on the left displays your query in左侧的“我的查询”窗格以mongo
shell syntax.mongo
shell语法显示您的查询。The pane to the right displays your query in the language selected.右侧的窗格以所选语言显示您的查询。 - (Optional)
: Check the Include Import Statements option to include the required import statements for the language selected.:选中“包含导入语句”选项以包含所选语言所需的导入语句。 - (Optional)
: Check the Include Driver Syntax option to include application code for the language selected.:选中“包含驱动程序语法”选项以包含所选语言的应用程序代码。If you include driver syntax, the copyable code reflects project, sort, maxtimems, collation, skip and limit options.如果包含驱动程序语法,可复制代码将反映投影、排序、maxtimems、排序规则、跳过和限制选项。 -
Click at the top-right of the formatted query to copy the query for the selected language to your clipboard.单击格式化查询右上角的,将所选语言的查询复制到剪贴板。You can now easily integrate and execute your created query in your application.现在,您可以轻松地在应用程序中集成和执行创建的查询。click to enlarge Click Close to return to the Documents Tab.单击“关闭”以返回“文档”选项卡。