我有这个东西
newSale {
productCode: 'MRS-GT-EN',
amount: 359.89,
serial: 4143,
orderNumber: 2241,
bookingDates: [
{ date: '9-1-2023', time: 6 },
{ date: '10-1-2023', time: 6 },
{ date: '11-1-2023', time: 6 },
{ date: '12-1-2023', time: 6 },
{ date: '13-1-2023', time: 6 },
{ date: '14-1-2023', time: 6 },
{ date: '15-1-2023', time: 6 },
{ date: '16-1-2023', time: 6 }
],
delivered: false
}
使用此架构:
const saleSchema = new Schema({
productCode: { type: String, required: true },
amount: { type: Number, required: true },
serial: { type: Number, required: true },
orderNumber: { type: Number, required: true},
bookindDates: [{date: {type: String}, time:{type:Number}}],
delivered: { type: Boolean, required: true }
}, { timestamps: true})
当我检查DB时,除了bookingDates
之外,它保存了所有内容,但留下了一个空数组。
我尝试了这个enter link description here,但没有成功。
我做错了什么,但我不知道是什么,你知道吗?
谢啦,谢啦
1条答案
按热度按时间p1tboqfb1#
您需要为
bookindDates
设置type
和default
属性,