字段ObjectId ref为null mongodb

时间:2018-07-27 00:29:34

标签: node.js mongodb

我有这个模型:

const schema = new Schema({
    title: {type: String, required: true},
    description: {type: String},
    absense: {type: Schema.Types.ObjectId, ref: 'Abscense'},
    contract: {type: Schema.Types.ObjectId, ref: 'Contract'},
    date: {type: Date},
    type: {type: String},
    discount_day: {type: Boolean, default: true},
    discount_vt: {type: Boolean, default: true},
    discount_vr: {type: Boolean, default: true},
    crm: {type: String},
    doctor_name: {type: String},
    child: {type: String}
});

但是在某些情况下,缺少字段是一个空值。可以将其设置为null吗?

0 个答案:

没有答案