Function: Index()
Call Signature
Index(
nameOrOptions?,options?):PropertyDecorator
Defined in: service-core/src/decorators/PersistenceDecorators.ts:169
Declares a database index.
When applied to a property, creates an index on that single property:
@Index() // unnamed index
@Index("myName") // named index
@Index({ unique: true }) // unnamed unique index
@Index("myName", { unique: true }) // named unique index
When applied to a class, creates a compound index across the given properties:
@Index(["firstName", "lastName"])
@Index("fullName", ["firstName", "lastName"], { unique: true })
Parameters
nameOrOptions?
string | IndexOptions
options?
Returns
PropertyDecorator
Call Signature
Index(
fields,options?):ClassDecorator
Defined in: service-core/src/decorators/PersistenceDecorators.ts:170
Declares a database index.
When applied to a property, creates an index on that single property:
@Index() // unnamed index
@Index("myName") // named index
@Index({ unique: true }) // unnamed unique index
@Index("myName", { unique: true }) // named unique index
When applied to a class, creates a compound index across the given properties:
@Index(["firstName", "lastName"])
@Index("fullName", ["firstName", "lastName"], { unique: true })
Parameters
fields
string[]
options?
Returns
ClassDecorator
Call Signature
Index(
name,fields,options?):ClassDecorator
Defined in: service-core/src/decorators/PersistenceDecorators.ts:171
Declares a database index.
When applied to a property, creates an index on that single property:
@Index() // unnamed index
@Index("myName") // named index
@Index({ unique: true }) // unnamed unique index
@Index("myName", { unique: true }) // named unique index
When applied to a class, creates a compound index across the given properties:
@Index(["firstName", "lastName"])
@Index("fullName", ["firstName", "lastName"], { unique: true })
Parameters
name
string
fields
string[]
options?
Returns
ClassDecorator