我想按照這個模型架構創建一個架構。
[
{
"_id": "617dda9ec688cc58f8db259e",
"location": "The Hunt Club",
"numbers": 12,
"available": [true, false]
}
]
到目前為止,我有以下代碼,但似乎不起作用:
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;
uj5u.com熱心網友回復:
在檔案https://mongoosejs.com/docs/guide.html 中
定義元素的型別,型別將被解釋。您可以使用本機型別String而不是"string"or Number。
numbers:{
type: Number,
required: true
},
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/350152.html
上一篇:獲取特定型別的所有書籍
