0
レコードをコレクションに追加するときに、配列オブジェクトをデフォルト値としてサブ配列に追加します。以下は私がこのコレクションにレコードを作成するときにASSIGNEE_WORKERS配列にデフォルトの配列を追加したい見ることができます私のchemaレコードをコレクションに追加するときに、Mongooseがデフォルトの配列オブジェクトをサブ配列に追加します。
const JobSpecificetionSchema = new Schema({
ACTIVITY:[{
DESCRIPTION: { type: String, default: '' },
SUB_ACTIVITY:[{
DESCRIPTION: { type: String, default: '' },
REPEAT_TYPE: { type: String, default: '' },// 1 - inspection will start 2 - inspection will not start
FREQUENCY: { type: String, default: '' }, // 1 - weekly, 2 - monthly, 3 - yearly
PAR_1: { type: String, default: '' }, // if weekly, then every one week or two. then monthly every one month or two months
PAR_2: { type: String, default: '' }, // if weekly then days in the week. ie (Monday 1, tue 2) (1,2,3) Monthly- day ie 25 yearly- month ie 1 to 12
PAR_3: { type: String, default: '' }, // if yearly then day 25
ASSIGNEE_WORKERS:[{
ASSIGNEE_ID : { type: Schema.Types.ObjectId, default: '000000000000000000000000' },
}]
}]
}]
});
を見つけてください。
現在の方法は機能しません。このために助けてください
私にいくつかの例を教えてください –