@@ -24,12 +24,15 @@ MongoDB applications use one of two methods for relating documents:
24
24
cases.
25
25
26
26
#. :ref:`DBRefs <dbref>` are references from one document to another
27
- using an ObjectId , and collection and database names for the target
28
- document. Resolving DBRefs requires two queries from your
27
+ using its _id field value , and collection, and (possibly) a database name, for the target
28
+ document. Resolving DBRefs requires queries from your
29
29
application; however, many :doc:`drivers </applications/drivers>`
30
- automatically resolve DBRefs. DBRefs are useful when you need to
31
- embed documents from multiple collections in documents from one
32
- collection.
30
+ have helper methods to resolve DBRefs without having to form the query manually.
31
+ No official driver automatically resolves DBRefs to documents for you; some frameworks and toolkits
32
+ provide automatically linking and (link) resolution if you wish to use these features.
33
+ DBRefs are useful when you need to embed documents from multiple collections in documents from one
34
+ collection. They also provide a common format and type for tools which can represent the link semantics provided
35
+ in your documents, or for interactions between frameworks which store linked documents.
33
36
34
37
Unless you have a compelling reason for using DBrefs, use manual
35
38
references.
@@ -98,8 +101,7 @@ Background
98
101
DBRefs are a convention for representing a :term:`document`, rather
99
102
than a specific reference "type." They include the name of the
100
103
collection, and in some cases the database, in addition to the
101
- ``ObjectId``. Some :term:`drivers <driver>` also have support for
102
- automatic resolution of DBRef references.
104
+ value from the _id field.
103
105
104
106
Format
105
107
~~~~~~
@@ -134,7 +136,7 @@ Thus a DBRef document would resemble the following:
134
136
.. note::
135
137
136
138
The order of fields in the DBRef matter, and you must use the above
137
- sequence when creating a DBRef.
139
+ sequence when using a DBRef.
138
140
139
141
Support
140
142
~~~~~~~
@@ -155,7 +157,7 @@ Support
155
157
156
158
**JavaScrpt**
157
159
The :program:`mongo` shell's :doc:`JavaScript </reference/javascript>`
158
- interface provides automatic resolution of DBRef objects .
160
+ interface provides a DBRef.
159
161
160
162
**Perl**
161
163
The Perl driver contains no support for DBRefs. You can transverse
@@ -167,8 +169,7 @@ Support
167
169
`The MongoDBRef class <http://www.php.net/manual/en/class.mongodbref.php/>`_.
168
170
169
171
**Python**
170
- The Python driver supports automatic resolution of DBRef
171
- relationships, and provides the :api:`DBref class <python/current/api/bson/dbref.html>`,
172
+ The Python driver provides the :api:`DBref class <python/current/api/bson/dbref.html>`,
172
173
and the :api:`dereference method </python/current/api/pymongo/database.html#pymongo.database.Database.dereference>`
173
174
for interacting with DBRefs.
174
175
0 commit comments