@@ -22,12 +22,17 @@ In this guide, you can learn about the following {+qe+} topics:
22
22
- Query types and which ones you can use on encrypted fields.
23
23
- What to consider when deciding whether to enable queries on an encrypted field.
24
24
25
- Specify Fields for Encryption
25
+ Specify Fields for Encryption
26
26
-----------------------------
27
27
28
- {+qe+} allows you to specify which fields you want to automatically
28
+ {+qe+} allows you to specify which fields you want to automatically
29
29
encrypt in your MongoDB document.
30
30
31
+ .. important::
32
+
33
+ You can specify any field in your document for encryption except the
34
+ ``_id`` field.
35
+
31
36
To specify fields for encryption and querying, define a JSON
32
37
schema that includes the following properties:
33
38
@@ -58,10 +63,10 @@ schema that includes the following properties:
58
63
Example
59
64
~~~~~~~
60
65
61
- This example shows how to create a JSON schema that specifies which fields that
66
+ This example shows how to create a JSON schema that specifies which fields that
62
67
the {+qe+} feature should automatically encrypt.
63
68
64
- Consider the following document that contains personally identifiable information
69
+ Consider the following document that contains personally identifiable information
65
70
(PII), credit card information, and sensitive medical information:
66
71
67
72
.. code-block:: json
@@ -84,8 +89,8 @@ Consider the following document that contains personally identifiable informatio
84
89
}
85
90
}
86
91
87
- To ensure the PII and sensitive medical information stays secure, create a JSON
88
- schema that configures {+qe+} to automatically encrypt those fields.
92
+ To ensure the PII and sensitive medical information stays secure, create a JSON
93
+ schema that configures {+qe+} to automatically encrypt those fields.
89
94
The following sample JSON schema shows how you can specify which fields to encrypt:
90
95
91
96
.. code-block:: javascript
@@ -115,24 +120,24 @@ The following sample JSON schema shows how you can specify which fields to encry
115
120
]
116
121
}
117
122
118
- Note that the ``keyId`` field requires a unique {+dek-long+} (DEK) which {+qe+}
119
- uses to encrypt the fields. For more information on DEKs, see
123
+ Note that the ``keyId`` field requires a unique {+dek-long+} (DEK) which {+qe+}
124
+ uses to encrypt the fields. For more information on DEKs, see
120
125
:ref:`qe-fundamentals-manage-keys`.
121
126
122
127
Specify Queryable Encrypted Fields
123
128
----------------------------------
124
129
125
- Include the ``queries`` property on fields you want to make queryable in your JSON
126
- schema. This enables an authorized client to issue read and write queries using
127
- encrypted fields. You can omit the ``queries`` property unless you want to be able
130
+ Include the ``queries`` property on fields you want to make queryable in your JSON
131
+ schema. This enables an authorized client to issue read and write queries using
132
+ encrypted fields. You can omit the ``queries`` property unless you want to be able
128
133
to query the field.
129
134
130
135
131
136
Example
132
137
~~~~~~~
133
138
134
- The following code snippet shows how to add the ``queries`` property to the
135
- JSON schema to make the ``patientId`` and ``patientInfo.ssn``
139
+ The following code snippet shows how to add the ``queries`` property to the
140
+ JSON schema to make the ``patientId`` and ``patientInfo.ssn``
136
141
fields queryable..
137
142
138
143
.. code-block:: javascript
@@ -172,8 +177,8 @@ Enable {+qe+}
172
177
173
178
You can enable {+qe+} on fields you specify in a JSON schema in the following ways:
174
179
175
- - Pass the JSON schema, represented by the ``encryptedFieldsObject`` constant,
176
- to the client that the application uses to create the collection as shown in the
180
+ - Pass the JSON schema, represented by the ``encryptedFieldsObject`` constant,
181
+ to the client that the application uses to create the collection as shown in the
177
182
following code snippet:
178
183
179
184
@@ -199,14 +204,14 @@ You can enable {+qe+} on fields you specify in a JSON schema in the following wa
199
204
200
205
.. note::
201
206
202
- It's important to enable {+qe+} before creating the collection. Enabling
203
- {+qe+} after creating the collection does not encrypt fields on documents
207
+ It's important to enable {+qe+} before creating the collection. Enabling
208
+ {+qe+} after creating the collection does not encrypt fields on documents
204
209
already in that collection.
205
210
206
- For more information on ``autoEncryption`` configuration options, see the
211
+ For more information on ``autoEncryption`` configuration options, see the
207
212
section on :ref:`qe-reference-mongo-client`.
208
213
209
- - Pass the encrypted fields object to your call to create a new collection as
214
+ - Pass the encrypted fields object to your call to create a new collection as
210
215
shown in the following code snippet:
211
216
212
217
.. code-block:: javascript
@@ -216,29 +221,29 @@ section on :ref:`qe-reference-mongo-client`.
216
221
});
217
222
218
223
.. tip::
219
-
220
- For the highest level of security, specify the encrypted fields both when
221
- creating the collection, and when creating a client to access the collection.
222
- This ensures that if the server's security is compromised, the information
224
+
225
+ For the highest level of security, specify the encrypted fields both when
226
+ creating the collection, and when creating a client to access the collection.
227
+ This ensures that if the server's security is compromised, the information
223
228
is still encrypted through the client.
224
229
225
230
.. important::
226
231
227
- MongoDB recommends explicitly creating your collection when using {+qe+}, rather
228
- than implicitly creating the collection through an insert operation. When you
229
- create a collection using ``createCollection()``, the operation creates an index
230
- on the encrypted fields. Without an index, querying on encrypted fields could
232
+ MongoDB recommends explicitly creating your collection when using {+qe+}, rather
233
+ than implicitly creating the collection through an insert operation. When you
234
+ create a collection using ``createCollection()``, the operation creates an index
235
+ on the encrypted fields. Without an index, querying on encrypted fields could
231
236
run slowly.
232
237
233
238
.. _qe-query-types:
234
239
235
240
Query Types
236
241
-----------
237
242
238
- {+qe+} allows you to specify on which fields you want to enable querying by passing
243
+ {+qe+} allows you to specify on which fields you want to enable querying by passing
239
244
a query type to the ``queries`` option in your encrypted fields object.
240
245
241
- {+qe+} supports the ``equality`` query type. The ``equality`` query type allows
246
+ {+qe+} supports the ``equality`` query type. The ``equality`` query type allows
242
247
you to query encrypted fields using the following expressions:
243
248
244
249
- :manual:`$eq </reference/operator/query/eq/>`
@@ -252,13 +257,13 @@ you to query encrypted fields using the following expressions:
252
257
- :manual:`$expr </reference/operator/query/expr/>`
253
258
254
259
.. note::
255
- Queries that compare an encrypted field to ``null`` or to a regular expression will
260
+ Queries that compare an encrypted field to ``null`` or to a regular expression will
256
261
result in an error, even when using a supported query operator.
257
262
258
263
.. _qe-query-unsupported:
259
264
260
- {+qe+} using the ``equality`` query type doesn't support read or write operations
261
- on a field when the operation compares the encrypted field to any of the following
265
+ {+qe+} using the ``equality`` query type doesn't support read or write operations
266
+ on a field when the operation compares the encrypted field to any of the following
262
267
:term:`BSON` types:
263
268
264
269
- ``double``
@@ -271,13 +276,13 @@ on a field when the operation compares the encrypted field to any of the followi
271
276
Considerations when Enabling Querying
272
277
-------------------------------------
273
278
274
- When you use {+qe+}, you can choose whether to make an encrypted field queryable.
275
- If you don't need to perform read operations, or write operations that require you
276
- to read an encrypted field, you may decide not to enable querying on that field.
279
+ When you use {+qe+}, you can choose whether to make an encrypted field queryable.
280
+ If you don't need to perform read operations, or write operations that require you
281
+ to read an encrypted field, you may decide not to enable querying on that field.
277
282
You can still retrieve the entire document by querying other fields that are queryable or not encrypted.
278
283
279
- When you make encrypted fields queryable, {+qe+} creates an index for each encrypted field, which
280
- can make write operations on that field take longer. When a write operation updates
284
+ When you make encrypted fields queryable, {+qe+} creates an index for each encrypted field, which
285
+ can make write operations on that field take longer. When a write operation updates
281
286
an indexed field, MongoDB also updates the related index.
282
287
283
288
When you enable querying on an encrypted field, your collection requires more storage space.
0 commit comments