Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

575
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!