From bc68b4dbf964bdd9221e2d02d4a36d938bed3db2 Mon Sep 17 00:00:00 2001 From: vchske Date: Thu, 26 Oct 2023 16:46:01 -0700 Subject: [PATCH] Minor changes to vcore mongo quickstart based on feedback (#1678) --- .../VCoreMongoQuickstartCommands.ts | 31 +++++--- .../Quickstart/VCoreMongoQuickstartGuide.tsx | 78 +++++++++++++++++-- 2 files changed, 89 insertions(+), 20 deletions(-) diff --git a/src/Explorer/Quickstart/VCoreMongoQuickstartCommands.ts b/src/Explorer/Quickstart/VCoreMongoQuickstartCommands.ts index b3d327109..27fbe4a12 100644 --- a/src/Explorer/Quickstart/VCoreMongoQuickstartCommands.ts +++ b/src/Explorer/Quickstart/VCoreMongoQuickstartCommands.ts @@ -1,5 +1,6 @@ export const newDbAndCollectionCommand = `use quickstartDB -db.createCollection('sampleCollection')`; +db.createCollection('sampleCollection') +`; export const newDbAndCollectionCommandForDisplay = `use quickstartDB // Create new database named 'quickstartDB' or switch to it if it already exists @@ -16,19 +17,25 @@ export const loadDataCommand = `db.sampleCollection.insertMany([ {title: "War and Peace", author: "Leo Tolstoy", pages: 1392}, {title: "The Odyssey", author: "Homer", pages: 374}, {title: "Ulysses", author: "James Joyce", pages: 730} - ])`; + ]) +`; -export const queriesCommand = `db.sampleCollection.find({author: "George Orwell"}) +export const findOrwellCommand = `db.sampleCollection.find({author: "George Orwell"}) +`; +export const findOrwellCommandForDisplay = `// Query to find all books written by "George Orwell" +db.sampleCollection.find({author: "George Orwell"})`; + +export const findByPagesCommand = `db.sampleCollection.find({pages: {$gt: 500}}) +`; + +export const findByPagesCommandForDisplay = `// Query to find all books with more than 500 pages db.sampleCollection.find({pages: {$gt: 500}}) +`; -db.sampleCollection.find({}).sort({pages: 1})`; +export const findAndSortCommand = `db.sampleCollection.find({}).sort({pages: 1}) +`; -export const queriesCommandForDisplay = `// Query to find all books written by "George Orwell" -db.sampleCollection.find({author: "George Orwell"}) - -// Query to find all books with more than 500 pages -db.sampleCollection.find({pages: {$gt: 500}}) - -// Query to find all books and sort them by the number of pages in ascending order -db.sampleCollection.find({}).sort({pages: 1})`; +export const findAndSortCommandForDisplay = `// Query to find all books and sort them by the number of pages in ascending order +db.sampleCollection.find({}).sort({pages: 1}) +`; diff --git a/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx b/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx index ea42bbce1..4fbb83484 100644 --- a/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx +++ b/src/Explorer/Quickstart/VCoreMongoQuickstartGuide.tsx @@ -11,11 +11,15 @@ import { } from "@fluentui/react"; import { customPivotHeaderRenderer } from "Explorer/Quickstart/Shared/QuickstartRenderUtilities"; import { + findAndSortCommand, + findAndSortCommandForDisplay, + findByPagesCommand, + findByPagesCommandForDisplay, + findOrwellCommand, + findOrwellCommandForDisplay, loadDataCommand, newDbAndCollectionCommand, newDbAndCollectionCommandForDisplay, - queriesCommand, - queriesCommandForDisplay, } from "Explorer/Quickstart/VCoreMongoQuickstartCommands"; import { useTerminal } from "hooks/useTerminal"; import React, { useState } from "react"; @@ -190,17 +194,17 @@ export const VcoreMongoQuickstartGuide: React.FC = (): JSX.Element => { useTerminal.getState().sendMessage(queriesCommand)} + onClick={() => useTerminal.getState().sendMessage(findOrwellCommand)} > Try query { iconProps={{ iconName: "Copy", }} - onClick={() => onCopyBtnClicked("#queriesCommand")} + onClick={() => onCopyBtnClicked("#findOrwellCommand")} + /> + + useTerminal.getState().sendMessage(findByPagesCommand)} + > + Try query + + + + onCopyBtnClicked("#findByPagesCommand")} + /> + + useTerminal.getState().sendMessage(findAndSortCommand)} + > + Try query + + + + onCopyBtnClicked("#findAndSortCommand")} /> @@ -236,7 +298,7 @@ export const VcoreMongoQuickstartGuide: React.FC = (): JSX.Element => { hosted in the cloud, to Azure Cosmos DB for MongoDB vCore.  Learn more