createUniqueIndex

Creates a UNIQUE INDEX.

This ensures that all values in the indexed column(s) are unique across all rows in the table. An attempt to insert or update a row that would violate this uniqueness constraint will fail.

You must chain this call with the Index.on function to specify which column(s) to include.

Example:

// Creates a unique index to ensure no two users have the same email.
createUniqueIndex("uidx_user_email").on(email)

Return

An Index instance to allow for method chaining, primarily with Index.on and optionally Index.where.

Author

MOHAMMAD AZIM ANSARI

Parameters

name

The name of the unique index. This name should be unique within the database.

See also