unique property

bool unique
final

When true, the column will be inserted with a UNIQUE constraint. Unique columns will also be listed in the adapter for querying if implemented by the invoking provider. Defaults to false. Does not apply to associations.

To index this column, index needs to be true. Indices are not automatically created for unique columns.

Some libraries may provide serializable classes (i.e. OfflineFirstSerdes) that can be used as a unique value. However, it is strongly, strongly discouraged to use anything more than a primitive for unique values. A complex class with multiple fields and methods will significantly confuse maintenance. A string or int or double is more than sufficient to determine a row's uniqueness. If a complex class must determine uniqueness, it is recommended to annotate a computed property with @Sqlite(unique:) instead of the class (e.g. String get id => serdes.toSqlite()).

Implementation

final bool unique;