Skip to content

Commit c4cbdc9

Browse files
committed
Update docs
1 parent 5939c9b commit c4cbdc9

File tree

4 files changed

+65
-33
lines changed

4 files changed

+65
-33
lines changed

docs/howto/queryable-encryption.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,28 +194,20 @@ Configuring the ``encrypted_fields_map``
194194

195195
When you :ref:`configure an encrypted database connection
196196
<qe-configuring-databases-setting>` without specifying an
197-
``encrypted_fields_map`` in
198-
:class:`pymongo.encryption_options.AutoEncryptionOpts`, Django MongoDB Backend
199-
will create an encrypted fields map for you (when ``python manage.py migrate``
200-
is run), including new data keys, and use it to create collections for models
201-
with encrypted fields.
202-
203-
The data keys are stored in the key vault :ref:`specified in the Django
204-
settings <qe-configuring-kms>`. You can view the encrypted fields map by running
205-
the :djadmin:`showencryptedfieldsmap` command.
197+
``encrypted_fields_map``, Django MongoDB Backend will create encrypted
198+
collections for you when you run ``python manage.py migrate``.
206199

207-
To see the keys created by Django MongoDB Backend in the above scenario, you can
208-
run the following command::
200+
Encryption keys for encrypted fields are stored in the key vault
201+
:ref:`specified in the Django settings <qe-configuring-kms>`. To see the keys
202+
created by Django MongoDB Backend, along with the entire schema, you can run the
203+
:djadmin:`showencryptedfieldsmap` command::
209204

210205
$ python manage.py showencryptedfieldsmap --database encrypted
211206

212-
You can then use the output of the :djadmin:`showencryptedfieldsmap` command
213-
to set the ``encrypted_fields_map`` in
207+
Use the output of the :djadmin:`showencryptedfieldsmap` command to set the
208+
``encrypted_fields_map`` in
214209
:class:`pymongo.encryption_options.AutoEncryptionOpts` in your Django settings.
215210

216-
Here is an example of how to configure the
217-
``encrypted_fields_map`` in your Django settings:
218-
219211
.. code-block:: python
220212
221213
from pymongo.encryption_options import AutoEncryptionOpts

docs/ref/models/encrypted-fields.rst

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ Queryable Encryption with Django MongoDB Backend.
1212
See the :doc:`/topics/queryable-encryption` topic guide for
1313
more information on developing applications with Queryable Encryption.
1414

15-
The following fields are supported by Django MongoDB Backend for use with
15+
The following Django fields are supported by Django MongoDB Backend for use with
1616
Queryable Encryption.
1717

1818
+----------------------------------------+------------------------------------------------------+
1919
| Encrypted Field | Django Field |
2020
+========================================+======================================================+
21-
| ``EncryptedBooleanField`` | :class:`~django.db.models.BooleanField` |
22-
+----------------------------------------+------------------------------------------------------+
2321
| ``EncryptedBigIntegerField`` | :class:`~django.db.models.BigIntegerField` |
2422
+----------------------------------------+------------------------------------------------------+
23+
| ``EncryptedBinaryField`` | :class:`~django.db.models.BinaryField` |
24+
+----------------------------------------+------------------------------------------------------+
25+
| ``EncryptedBooleanField`` | :class:`~django.db.models.BooleanField` |
26+
+----------------------------------------+------------------------------------------------------+
2527
| ``EncryptedCharField`` | :class:`~django.db.models.CharField` |
2628
+----------------------------------------+------------------------------------------------------+
2729
| ``EncryptedDateField`` | :class:`~django.db.models.DateField` |
@@ -52,13 +54,32 @@ Queryable Encryption.
5254
+----------------------------------------+------------------------------------------------------+
5355
| ``EncryptedURLField`` | :class:`~django.db.models.URLField` |
5456
+----------------------------------------+------------------------------------------------------+
57+
| ``EncryptedUUIDField`` | :class:`~django.db.models.UUIDField` |
58+
+----------------------------------------+------------------------------------------------------+
5559

56-
The following fields are supported by Django MongoDB Backend but are not
57-
supported by Queryable Encryption.
60+
The following MongoDB-specific fields are supported by Django MongoDB Backend
61+
for use with Queryable Encryption.
62+
63+
+----------------------------------------+------------------------------------------------------+
64+
| Encrypted Field | MongoDB Field |
65+
+----------------------------------------+------------------------------------------------------+
66+
| ``EncryptedArrayField`` | :ref:`arrayfield` |
67+
+----------------------------------------+------------------------------------------------------+
68+
| ``EncryptedEmbeddedModelArrayField`` | :ref:`embeddedmodelarrayfield` |
69+
+----------------------------------------+------------------------------------------------------+
70+
| ``EncryptedEmbeddedModelField`` | :ref:`embeddedmodelfield` |
71+
+----------------------------------------+------------------------------------------------------+
72+
| ``EncryptedObjectIdField`` | :ref:`objectidfield` |
73+
+----------------------------------------+------------------------------------------------------+
74+
75+
The following fields are supported by Django MongoDB Backend but not by
76+
Queryable Encryption.
5877

59-
+--------------------------------------+-----------------------------------------------+
60-
| :class:`~django.db.models.SlugField` | Indexes aren't supported on encrypted fields. |
61-
+--------------------------------------+-----------------------------------------------+
78+
+--------------------------------------+--------------------------------------------------------------------------------------------------------------------+
79+
| Field | Limitation |
80+
+--------------------------------------+--------------------------------------------------------------------------------------------------------------------+
81+
| :class:`~django.db.models.SlugField` | :ref:`Queryable Encryption does not support TTL Indexes or Unique Indexes <manual:qe-reference-encryption-limits>` |
82+
+--------------------------------------+--------------------------------------------------------------------------------------------------------------------+
6283

6384
``EncryptedFieldMixin``
6485
=======================

docs/ref/models/fields.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ MongoDB-specific model fields
4646

4747
Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
4848

49+
.. _arrayfield:
50+
4951
``ArrayField``
5052
--------------
5153

@@ -260,6 +262,8 @@ transform do not change. For example:
260262
261263
These indexes use 0-based indexing.
262264

265+
.. _embeddedmodelfield:
266+
263267
``EmbeddedModelField``
264268
----------------------
265269

@@ -310,6 +314,8 @@ These indexes use 0-based indexing.
310314
created these models and then added an indexed field to ``Address``,
311315
the index created in the nested ``Book`` embed is not created.
312316

317+
.. _embeddedmodelarrayfield:
318+
313319
``EmbeddedModelArrayField``
314320
---------------------------
315321

@@ -346,6 +352,8 @@ These indexes use 0-based indexing.
346352
This field is typically the default primary key field for all models stored
347353
in MongoDB. See :ref:`specifying the-default-pk-field`.
348354

355+
.. _objectidfield:
356+
349357
``ObjectIdField``
350358
-----------------
351359

docs/topics/queryable-encryption.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,36 @@ Queryable Encryption
44

55
.. versionadded:: 5.2.3
66

7-
Once you have configured your Django project and MongoDB deployment for
8-
Queryable Encryption, you’re ready to start developing applications that take
9-
advantage of these enhanced security features.
7+
Once you have successfully set up MongoDB Queryable Encryption as described in
8+
:doc:`the installation guide </howto/queryable-encryption>`, you can start
9+
using encrypted fields in your Django models.
1010

1111
Encrypted fields
1212
================
1313

14-
You can use :doc:`encrypted fields </ref/models/encrypted-fields>` to structure
15-
your sensitive data.
16-
17-
1814
The basics
1915
----------
2016

21-
For example, you can define models with encrypted fields like this:
17+
:doc:`Encrypted fields </ref/models/encrypted-fields>` may be used to protect
18+
sensitive data like social security numbers, credit card information, or
19+
personal health information. With Queryable Encryption, you can also perform
20+
queries on certain encrypted fields. To use encrypted fields in your models,
21+
import the necessary field types from ``django_mongodb_backend.models`` and
22+
define your models as usual.
2223

2324
.. code-block:: python
2425
25-
class Patient(EncryptedTestModel):
26+
# myapp/models.py
27+
from django.db import models
28+
from django_mongodb_backend.models import EmbeddedModel
29+
from django_mongodb_backend.fields import (
30+
EmbeddedModelField,
31+
EncryptedCharField,
32+
EncryptedEmbeddedModelField,
33+
)
34+
35+
36+
class Patient(models.Model):
2637
patient_name = models.CharField(max_length=255)
2738
patient_id = models.BigIntegerField()
2839
patient_record = EmbeddedModelField("PatientRecord")

0 commit comments

Comments
 (0)