import mongoose, { Schema, model } from "mongoose";
var breakfastSchema = new Schema({
eggs: {
type: Number,
min: [6, "Too few eggs"],
max: 12
},
bacon: {
type: Number,
required: [true, "Why no bacon?"]
},
drink: {
type: String,
enum: ["Coffee", "Tea"],
required: function() {
return this.bacon > 3;
}
}
});
The two errors that I get when I run this code are:
- Property 'bacon' does not exist on type '{ type: StringConstructor; enum: string[]; required: () => any; }'
- 'required' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.