|
12 | 12 | :depth: 1
|
13 | 13 |
|
14 | 14 | The ``/schema`` command provides information about your collection
|
15 |
| -schema. The |copilot| accesses your connected MongoDB deployment to |
16 |
| -provide schema information in the Copilot generated response. |
| 15 | +schema by accessing your connected MongoDB deployment. |
17 | 16 |
|
18 | 17 | Examples
|
19 | 18 | --------
|
20 | 19 |
|
21 | 20 | Provide a Sample Document
|
22 | 21 | ~~~~~~~~~~~~~~~~~~~~~~~~~
|
23 | 22 |
|
24 |
| -Consider the ``users`` collection in the `Mflix Sample Database |
| 23 | +This example uses the ``users`` collection in the `Mflix Sample Database |
25 | 24 | <https://www.mongodb.com/docs/atlas/sample-data/sample-mflix/#sample_mflix.users>`__.
|
| 25 | +Each document in the collection has the following structure: |
| 26 | + |
| 27 | +.. code-block:: none |
| 28 | + :copyable: false |
| 29 | + |
| 30 | + { |
| 31 | + "_id": { |
| 32 | + "$oid": "59b99db4cfa9a34dcd7885b6" |
| 33 | + }, |
| 34 | + "name": "Ned Stark", |
| 35 | + |
| 36 | + "password": "$2b$12$UREFwsRUoyF0CRqGNK0LzO0HM/jLhgUCNNIJ9RJAqMUQ74crlJ1Vu" |
| 37 | + } |
| 38 | + |
| 39 | + |
26 | 40 | If you are connected to a MongoDB deployment that contains this
|
27 |
| -collection, you can ask the |copilot| to provide a sample document: |
| 41 | +collection, you can ask the |copilot| to show the schema of your collection: |
28 | 42 |
|
29 | 43 | .. code-block:: none
|
30 | 44 | :copyable: false
|
31 | 45 |
|
32 |
| - @MongoDB /schema Can you show a sample document from the |
| 46 | + @MongoDB /schema @MongoDB /schema Can you show the schema for the |
33 | 47 | sample_mflix.users collection?
|
34 | 48 |
|
35 | 49 | GitHub Copilot uses the |copilot| to generate the following response:
|
36 | 50 |
|
37 | 51 | .. code-block:: none
|
38 | 52 | :copyable: false
|
39 | 53 |
|
40 |
| - Sure, here is a sample document from the sample_mflix.users |
41 |
| - collection: |
42 |
| - |
| 54 | + The schema for the sample_mflix.users collection, based on 100 |
| 55 | + sampled documents, is as follows: |
| 56 | + |
43 | 57 | {
|
44 | 58 | "_id": {
|
45 |
| - "$oid": "5f8473b823bca94021aa1c45" |
| 59 | + "type": "ObjectId", |
| 60 | + "probability": 1 |
| 61 | + }, |
| 62 | + "email": { |
| 63 | + "type": "String", |
| 64 | + "probability": 1 |
46 | 65 | },
|
47 |
| - |
48 |
| - "name": "John Doe", |
49 |
| - "password": "password123", |
50 |
| - "preferences": {} |
| 66 | + "name": { |
| 67 | + "type": "String", |
| 68 | + "probability": 1 |
| 69 | + }, |
| 70 | + "password": { |
| 71 | + "type": "String", |
| 72 | + "probability": 1 |
| 73 | + }, |
| 74 | + "preferences": { |
| 75 | + "type": ["Document", "Undefined"], |
| 76 | + "probability": 0.01 |
| 77 | + } |
51 | 78 | }
|
52 | 79 |
|
53 |
| -Once Copilot generates the response, you can open the JSON output to see |
54 |
| -more information. |
| 80 | + Key Points: |
| 81 | + |
| 82 | + - Fields _id, email, name, and password appear in all documents with |
| 83 | + a probability of 1. |
| 84 | + - The preferences field is mostly undefined but occasionally contains |
| 85 | + a document (1% probability). |
| 86 | + |
| 87 | +After Copilot generates the response, you can open the output in JSON format. |
55 | 88 |
|
56 | 89 | .. figure:: /images/copilot-schema.png
|
57 | 90 | :figwidth: 600px
|
|
0 commit comments