Closed Ena-Heleneto closed 8 months ago
First I have a model like this
const templateSchema = { templateId: [{ type: String, required: [true, '未插入模板id'], index: true }], name: [{ type: String, required: [true, '未插入类型名称'], index: true }], version: [{ type: String, required: [true, '未插入版本号'], index: false }], status: [{ type: Number, required: [true, '未插入启用状态'], index: false }], process: [{ type: {}, required: [true, '未插入流程'], index: false }], createDate: [{ type: Date, required: [true, '未插入创建时间'], index: false }], updateDate: [{ type: Date, required: [false, '未插入创建时间'], index: false }], founderId: [{ type: Number, required: [true, '未插入创建人id'], index: false }], deleteFlag: [{ type: Number, required: [true, '未插入删除标志'], index: false }], } const SystemTemplates = defineMongooseModel('HW_Templates', templateSchema, { collection: 'HW_Templates' })
Next, I'll perform the insert
SystemTemplates.create({ templateId: `temp${new Date().getTime()}`, createDate: new Date(), updateDate: new Date(), founderId: 1, status: 1, deleteFlag: 0, })
But I got this
The data is converted to array type
I don't know what happened, is it a new feature?
devDependencies Version{ "nuxt-mongoose": "^1.0.2" }
You just need to remove the [ ] from schema props, example: name: { type: String, required: [true, 'custom error'], index: true },
[ ]
name: { type: String, required: [true, 'custom error'], index: true },
ooh, I understand, thank you
First I have a model like this
Next, I'll perform the insert
But I got this
The data is converted to array type
I don't know what happened, is it a new feature?
devDependencies Version{ "nuxt-mongoose": "^1.0.2" }