Skip to content

Commit 744f456

Browse files
committed
Add documentation on #[Encrypt] attribute
1 parent 81f3e90 commit 744f456

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/en/reference/attributes-reference.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,40 @@ Unlike normal documents, embedded documents cannot specify their own database or
336336
collection. That said, a single embedded document class may be used with
337337
multiple document classes, and even other embedded documents!
338338

339+
#[Encrypt]
340+
----------
341+
342+
The `#[Encrypt]` attribute is used to define an encrypted field mapping for a document property. It allows you to configure fields for encryption and queryable encryption in MongoDB.
343+
344+
Optional arguments:
345+
346+
- ``queryType`` - Specifies the query type for the field. Possible values:
347+
- ``null`` (default) - Field is not queryable.
348+
- ``QUERY_TYPE_EQUALITY`` - Enables equality queries.
349+
- ``QUERY_TYPE_RANGE`` - Enables range queries.
350+
- ``min``, ``max`` - Specify minimum and maximum (inclusive) queryable values fora field when possible, as smaller bounds improve query efficiency. If querying values outside of these bounds, MongoDB returns an error.
351+
- ``sparsity``, ``prevision``, ``trimFactor``, ``contention`` - For advanced users only. The default values for these options are suitable for the majority of use cases, and should only be modified if your use case requires it.
352+
353+
Example:
354+
355+
.. code-block:: php
356+
357+
<?php
358+
359+
use Doctrine\ODM\MongoDB\Mapping\Annotations\Encrypt;
360+
361+
#[Document]
362+
class Client
363+
{
364+
// ...
365+
366+
#[Field]
367+
#[Encrypt(queryType: Encrypt::QUERY_TYPE_EQUALITY)]
368+
public string $name;
369+
}
370+
371+
For more details, refer to the MongoDB documentation on [Queryable Encryption](https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/encrypt-and-query/).
372+
339373
#[Field]
340374
--------
341375

0 commit comments

Comments
 (0)