# MongooseIndex Decorator mongoose class

Module
import { MongooseIndex } from "@tsed/mongoose"
Source/packages/mongoose/src/decorators/mongooseIndex.ts

# Overview

function MongooseIndex(fields: object, options?: any): Function;

# Description

Calls schema.index() to define an index (most likely compound) for the schema.

# Example

@Model()
@MongooseIndex({first: 1, second: 1}, {unique: 1})
export class EventModel {

  @Property()
  first: string;

  @Property()
  second: string;

}
1
2
3
4
5
6
7
8
9
10
11