Define a unique constraint.
The constraint definition is an Array of document field names that are constrained to unique values.
You can define a constraint on a field that has the
mva flag set. See
for a description of the multivalued attribute flag (MVA).
Document field to constrained to a unique value.
In the example, the
username must be unique in the collection.
A unique constraint can define multiple fields that must be unique in
combination. If the
name.last fields in the example are
defined as a unique constraint, the first and last name combination must be
unique for the collection.
If you create a unique constraint over more than one field, the absence of
one or more fields with the presence of other fields in the unique constraint
is a combination that the constraint is enforced over. In the first and last
name example, if you create a user and populate only the
you can’t create another user with only the same last name, but you can create
another user with the same last name if you also define a
When one or more fields are part of a unique constraint, multiple documents can’t have the same combination of values for the constrained fields.
Is this article helpful?
Tell Fauna how the article can be improved:
Thank you for your feedback!