EntityIndex class
An index of an entity's table over one or more fields (in this order): a composite index, which EntityField.indexed (one field) can't express.
@EnableReflection()
@EntityIndex(['establishment', 'creationDate'])
class OrderClosing extends Entity { ... }
- fields: the entity's field names (not the columns' names); a
reference field (e.g.
EntityReference<Establishment>) is its column. Collection (relationship) fields can't be indexed. - name: the index name; default:
<table>__<column1>_<column2>__idx(__uniqueif unique; shortened with a hash past the dialect's identifier limit). Index names are unique per schema in PostgreSQL and SQLite (not per table). - unique: the fields' values are unique together (a composite unique
constraint, which EntityField.unique (one field) can't express):
@EntityIndex(['establishment', 'day'], unique: true) class SalesDay extends Entity { ... }CONSTRAINT "sales_day__establishment_day__unique" UNIQUE ("establishment", "day").
Generated with the table (CREATE INDEX, or a UNIQUE constraint);
checked by checkTables (an existing table without an index over these
columns, in this order, unique if unique, is reported with the SQL to
create it).
- Inheritance
-
- Object
- EntityAnnotation
- EntityIndex
- Annotations
-
- @Target({TargetKind.classType})
Constructors
-
EntityIndex(List<
String> fields, {String? name, bool unique = false}) -
const
Properties
-
fields
→ List<
String> -
The indexed fields, in the index's order.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- name → String?
-
The index name (
null: the default name).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- unique → bool
-
Whether the fields' values are unique together (a
UNIQUEconstraint).final
Methods
-
indexName(
String table, List< String> columns, {int? maxLength}) → String -
The index name of
tableovercolumns: name or defaultName. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override