How would you define a schema for a Product with a required name (string), optional price (number), and a default inStock (boolean) set to true?
A@Schema()
export class Product {
@Prop({ required: true })
name: string;
@Prop()
price?: number;
@Prop({ default: true })
inStock: boolean;
}
B@Schema()
export class Product {
@Prop()
name: string;
@Prop({ required: true })
price: number;
@Prop({ default: false })
inStock: boolean;
}
C@Schema()
export class Product {
@Prop({ required: true })
name: number;
@Prop()
price: string;
@Prop({ default: true })
inStock: boolean;
}
D@Schema()
export class Product {
@Prop({ required: true })
name: string;
@Prop({ default: 0 })
price: number;
@Prop()
inStock: boolean;
}