Index class

Indicates that a field or a combination of fields should be indexed.

When applied to a field, that field alone will be indexed. When applied to a class, specify the columns that form a composite index.

Example (Field):

@Entity()
class User {
  @Index()
  @Column()
  late String email;
}

Example (Class - Composite):

@Entity()
@Index(name: 'idx_name_org', columns: ['name', 'orgId'])
class Person {
  @Column()
  late String name;
  @Column()
  late int orgId;
}
Annotations
  • @Target.new({TargetKind.field, TargetKind.classType})

Constructors

Index({String? name, List<String>? columns, bool unique = false})
const

Properties

columns List<String>?
List of column names for composite indexes. Only used when applied to a class.
final
hashCode int
The hash code for this object.
no setterinherited
name String?
Optional name for the index.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unique bool
Whether the index should be unique.
final

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