# Decorator MongooseIndexes

Decorator mongoose class private
Module
import { MongooseIndexes } from "@tsed/mongoose/src/decorators/mongooseIndexes"
Source/packages/mongoose/src/decorators/mongooseIndexes.ts

# Overview

function MongooseIndexes(indexes: Array<{
    fields: object;
    options?: any;
}>): Function;

# Description

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

# Example

@Model()
@MongooseIndexes([{fields: {first: 1, second: 1}, options:{unique: 1}}, {fields: {first: 1, third: 1}, options:{unique: 1}}])
export class EventModel {

  @Property()
  first: string;

  @Property()
  second: string;

  @Property()
  third: string;

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

# Members

fields: object;

options?: any;

Other topics