Unique class
Indicates that a field or a combination of fields must be unique.
When applied to a field, that field alone will have a unique constraint. When applied to a class, specify the columns that form a composite unique constraint.
Example (Field):
@Entity()
class User {
@Unique()
@Column()
late String email;
}
Example (Class - Composite):
@Entity()
@Unique(name: 'uidx_name_org', columns: ['name', 'orgId'])
class Person {
@Column()
late String name;
@Column()
late int orgId;
}
- Annotations
-
- @Target.new({TargetKind.field, TargetKind.classType})
Properties
-
columns
→ List<
String> ? -
List of column names for composite unique constraints.
Only used when applied to a class.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String?
-
Optional name for the unique constraint.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited