Index

Indexes are database indexes. With Teo, you can define primary index, normal index and unique index on both model level and field level.

Index types

  • primary this index is used as primary key
  • unique this index is unique
  • index a normal index

Both primary and unique are unique.

Field index

Field index is defined directly on the field.

model Demo {
  @index
  createdAt: DateTime
 
  @unique
  email: String?
 
  @id
  id: Int
}

Compound index

Any field index can be defined on model, too. If an index is compound and it consists of multiple fields, it can only be defined on model.

@id([.userId, .productId])
@unique([.singer, .year])
model Demo {
  // ...
}