Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

572
Vistas
NestJs index field with mongoose

I have a question about how to index fields in Mongoose collections on NestJS. Is the indexing method done correctly in the following example? Do I have to set the autoindex field value to false at the schema level and then true the index value at the field level to be indexed?

@Schema({ timestamps: true, autoIndex: false })
export class Ticket {
  @Prop({ required: true, index: true })
  title: string;

  @Prop({ required: true, index: true })
  name: string;

  @Prop({ type: ContactModelSchema })
  contact: ContactModel;

  @Prop({ type: ContentModelSchema, index: true })
  acceptedContent: ContentModel;
}

export const TicketSchema = SchemaFactory.createForClass(Ticket);

@Schema({ timestamps: true, _id: false, autoIndex: false })
export class ContentModel {
  @Prop()
  websiteUrl: string;

  @Prop({ index: true })
  body: string;

  @Prop()
  galleryUrls: [string];

  @Prop()
  voiceUrl: string;

  @Prop({ type: VideoModelSchema })
  video: VideoModel;

  @Prop({ type: [String], index: true })
  tags: string[];

  @Prop({ type: LocationModelSchema, index: true })
  location: LocationModel;


}

export const ContentModelSchema = SchemaFactory.createForClass(ContentModel);
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda