I would like to create a schema following this model schema.
[
{
"_id": "617dda9ec688cc58f8db259e",
"location": "The Hunt Club",
"numbers": 12,
"available": [true, false]
}
]
So far I have the below code, but does not seems to be working:
const locationSchema = new mongoose.Schema({
location: {
type: "string",
required: true
},
numbers:{
type: "number",
required: true
},
available:{
type:[Boolean],
required: true
},
date:{
type:Date,
default:Date.now,
}
})
const locations = mongoose.model('location', locationSchema);
module.exports = locations;
CodePudding user response:
In the documentation https://mongoosejs.com/docs/guide.html
For defining the type of the element, the type will be interpreted. You could use the native type String
instead of "string"
or Number
.
numbers:{
type: Number,
required: true
},