@@ -9,7 +9,7 @@ Database References
9
9
.. contents:: On this page
10
10
:local:
11
11
:backlinks: none
12
- :depth: 1
12
+ :depth: 2
13
13
:class: singlecol
14
14
15
15
For many use cases in MongoDB, the denormalized data model where
@@ -29,6 +29,11 @@ or databases.
29
29
This page outlines alternative procedures that predate the
30
30
:pipeline:`$lookup` and :pipeline:`$graphLookup` pipeline stages.
31
31
32
+ You can create a database reference for deployments hosted in the
33
+ following environments:
34
+
35
+ .. include:: /includes/fact-environments.rst
36
+
32
37
MongoDB applications use one of two methods to relate documents:
33
38
34
39
- :ref:`Manual references <document-references>` save the
@@ -69,8 +74,75 @@ A manual reference is the practice of including one
69
74
application can then issue a second query to resolve the referenced
70
75
fields as needed.
71
76
72
- Process
73
- ~~~~~~~
77
+ Create a Manual Reference in the {+atlas+} UI
78
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
+
80
+ To create a manual reference in the {+atlas+} UI, follow these steps:
81
+
82
+ .. procedure::
83
+ :style: normal
84
+
85
+ .. step:: Navigate to the collection.
86
+
87
+ a. In the {+atlas+} UI, click :guilabel:`Database` in the sidebar.
88
+ #. For the database deployment where you want to add a database
89
+ reference, click :guilabel:`Browse Collections`.
90
+ #. In the left navigation pane, select the database.
91
+ #. In the left navigation pane, select the collection. This
92
+ example references a ``places`` collection.
93
+
94
+ .. step:: Add a document.
95
+
96
+ a. Click :guilabel:`Insert Document`.
97
+ #. Click the JSON view icon (:guilabel:`{{}}`).
98
+ #. Paste the following data into the document:
99
+
100
+ .. code-block::
101
+
102
+ {
103
+ "_id": {
104
+ "$oid": "651aea5870299b120736f442"
105
+ },
106
+ "name": "Broadway Center",
107
+ "url": "bc.example.net"
108
+ }
109
+
110
+ #. Click :guilabel:`Insert`.
111
+
112
+ .. step:: Add a document in the ``people`` collection that references the entry in ``places``.
113
+
114
+ a. In the left navigation pane, select a different
115
+ collection. This example references a ``people`` collection.
116
+ #. Click :guilabel:`Insert Document`.
117
+ #. Click the JSON view icon (:guilabel:`{{}}`).
118
+ #. Paste the following data into the document:
119
+
120
+ .. code-block::
121
+
122
+ {
123
+ "_id": {
124
+ "$oid": "651aebeb70299b120736f443"
125
+ },
126
+ "name": "Erin",
127
+ "places_id": "651aea5870299b120736f442"
128
+ "url": "bc.example.net/Erin"
129
+ }
130
+
131
+ #. Click :guilabel:`Insert`.
132
+
133
+ When a query returns the document from the ``people``
134
+ collection you can, if needed, filter the query results from
135
+ the ``places`` collection for the document referenced by the
136
+ ``places_id`` field.
137
+
138
+ To learn more about running queries in {+atlas+},
139
+ see :atlas:`View, Filter, and Sort Documents
140
+ </atlas-ui/documents/#view--filter--and-sort-documents>` in
141
+ the {+atlas+} documentation.
142
+
143
+
144
+ Create a Manual Reference in the Terminal
145
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
146
75
147
Consider the following operation to insert two documents, using the
76
148
``_id`` field of the first document as a reference in the second
0 commit comments