Skip to content

Commit 5adb7b1

Browse files
committed
DOCSP-43493 adding screenshots
1 parent 1d4d0a6 commit 5adb7b1

File tree

4 files changed

+135
-70
lines changed

4 files changed

+135
-70
lines changed

source/copilot-query.txt

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,29 @@ value of ``Kayden Washington``.
5151
.. code-block:: javascript
5252
:copyable: false
5353

54-
@MongoDB /query find a document in the users collection with the name
55-
of Kayden Washington.
54+
@MongoDB /query In the sample_mflix database, find a document in the
55+
users collection with the name of Kayden Washington.
5656

5757
The Github Copilot Chat uses the |copilot| to
5858
generate the following query using knowledge of your database schema:
5959

6060
.. code-block:: javascript
6161

62+
use(`sample_mflix`);
6263
db.getCollection('users').findOne({ name: 'Kayden Washington' });
6364

6465
Once the |copilot| generates the query, you can choose to run the query
6566
directly or open the query in a playground.
6667

67-
.. figure:: /images/copilot-query.png
68-
:figwidth: 700px
69-
:alt: Image copilot generating a query
68+
.. figure:: /images/copilot-query.png
69+
:figwidth: 700px
70+
:alt: Screenshot of copilot generating a query
7071

7172
Build an Aggregation Pipeline
7273
`````````````````````````````
7374

74-
You can also use the |copilot| to build aggregation pipelines. Consider the ``users`` collection in the `Mflix Sample Database
75+
You can also use the |copilot| to build aggregation pipelines. Consider
76+
the ``users`` collection in the `Mflix Sample Database
7577
<https://www.mongodb.com/docs/atlas/sample-data/sample-mflix/#sample_mflix.users>`__.
7678
Each document in the collection has the following structure:
7779

@@ -101,13 +103,19 @@ The |copilot| generates the following aggregation pipeline:
101103

102104
.. code-block:: javascript
103105

106+
use('sample_mflix');
104107
db.getCollection('users').aggregate([
105-
// First stage: Sort documents alphabetically by name
106108
{ $sort: { name: 1 } },
107-
// Second stage: Remove the password field from each document
108-
{ $unset: "password" }
109+
{ $project: { password: 0 } }
109110
]);
110111

112+
Once the |copilot| generates the query, you can choose to run the pipeline
113+
directly or open the pipeline in a playground.
114+
115+
.. figure:: /images/copilot-agg-pipeline.png
116+
:figwidth: 700px
117+
:alt: Screenshot of copilot generating an aggregation pipeline
118+
111119
You can also iteratively build on your aggregation pipeline:
112120

113121
.. code-block:: javascript
@@ -121,11 +129,13 @@ The |copilot| returns the following aggregation pipeline:
121129

122130
.. code-block:: javascript
123131

132+
use('sample_mflix');
124133
db.getCollection('users').aggregate([
125134
{ $sort: { name: 1 } },
126135
{ $project: { password: 0 } },
127-
{ $addFields:
128-
{ username: { $arrayElemAt:
129-
[{ $split: ["$email", "@"] }, 0] } } },
130-
{ $out: "sortedUsersWithUsernames" }
136+
{ $addFields: { username: { $arrayElemAt: [{ $split: ["$email", "@"] }, 0] } } }
131137
]);
138+
139+
.. figure:: /images/copilot-agg-pipeline2.png
140+
:figwidth: 700px
141+
:alt: Screenshot of copilot iteratively building on an aggregation pipeline

source/images/copilot-agg-pipeline.png

Lines changed: 47 additions & 0 deletions
Loading

source/images/copilot-agg-pipeline2.png

Lines changed: 47 additions & 0 deletions
Loading

source/images/copilot-query.png

Lines changed: 18 additions & 57 deletions
Loading

0 commit comments

Comments
 (0)