0

this is my schema

export type OnSaleListDocument = OnSaleList & Document;
@Schema({ autoIndex: true })
export class OnSaleList {
  @Prop()
  id: number;

  @Prop()
  address: string;

  @Prop()
  quantity: number;

  @Prop()
  price: number;
}
const OnSaleListSchema = SchemaFactory.createForClass(OnSaleList);
OnSaleListSchema.index({ id: 1, address: 1 }, { unique: true });
export { OnSaleListSchema };

I am not able to get the desired results. It is taking id as the unique field. I want both of them to act as a unique field together, not separately.

0 Answers0