停止猫鼬为子文档数组项创建_id属性如果您有子文档数组,则Monose会自动为每个子文档数组创建ID。例子:{
_id: "mainId"
subDocArray: [
{
_id: "unwantedId",
field: "value"
},
{
_id: "unwantedId",
field: "value"
}
]}是否有一种方法可以告诉Monose不要为数组中的对象创建ID?
3 回答
摇曳的蔷薇
TA贡献1793条经验 获得超6个赞
var mongoose = require("mongoose");var subSchema = mongoose.Schema({ //your subschema content},{ _id : false });var schema = mongoose.Schema({ // schema content subSchemaCollection : [subSchema]});var model = mongoose.model('tablename', schema);
偶然的你
TA贡献1841条经验 获得超3个赞
var schema = new mongoose.Schema({ field1:{type:String}, subdocArray:[{ _id:false, field :{type:String} }]});
- 3 回答
- 0 关注
- 640 浏览
添加回答
举报
0/150
提交
取消