i need a _id for my subdocuments but it set default to null,but the field _id id generated automatically but the value set to null, i tried in many ways but is default value null is not changed.
method 1
const event_Schema = mongoose.Schema({
bid: {
type: String,
},
name: {
type: String,
},
start_date: {
type: String,
},
end_date: {
type: String,
},
start_time: {
type: String,
},
end_time: {
type: String,
},
slot_duration: {
type: String,
},
excuse: {
type: String,
},
slots: [
{
date: { type: String },
slots: [
{
uid: {
type: String,
},
start_time: {
type: String,
},
end_time: {
type: String,
},
attachment: {
type: String,
},
description: {
type: String,
},
available: {
type: Boolean,
},
status: {
type: String,
//default: 'unbook',
},
},
],
},
],
})
Method 2
const slot_Schema = mongoose.Schema({
uid: {
type: String,
},
start_time: {
type: String,
},
end_time: {
type: String,
},
attachment: {
type: String,
},
description: {
type: String,
},
available: {
type: Boolean,
},
status: {
type: String,
},
})
const slots_Schema = mongoose.Schema({
date: { type: String },
slots: [slot_Schema],
})
const event_Schema = mongoose.Schema({
bid: {
type: String,
},
name: {
type: String,
},
start_date: {
type: String,
},
end_date: {
type: String,
},
start_time: {
type: String,
},
end_time: {
type: String,
},
slot_duration: {
type: String,
},
excuse: {
type: String,
},
slots: [slots_Schema],
})
is there is any way to resove this or i need to use any other 3rd party packages to generate _id
version: "mongoose": "^6.6.5",