Classes marked with @model decorator are schema definitions and the main point to query the database.

function model<T>(options: ModelOptions): ClassDecorator


The decorator accepts an object with the following properties:

export interface ModelOptions<T> {
  collection?: string
  indexes?: ModelIndex<T>[]
  connection?: Connection


collectionstringBy default a collection name is generated from the class name. You can change this by providing a custom name.
indexesModelIndex<T>[]An array of indexes to apply on this collection. The same thing can be achieved using @index decorator. Basic indexes like unique can also be specified in the @field decorator
connectionConnectionIf this collection is in a different database, the connection object can be specified here.