如何让mongoose不创建不必要的_id?

时间:2016-03-15 14:13:15

标签: node.js mongodb mongoose mongoose-schema

new mongoose.Schema({
  name: String,
  posts: [{
    title: String,
    body: String,
  }]
})

我会得到像

这样的东西
{
  "_id": ObjectId("xxx"), // which is OK
  "name": "xxx",
  "posts": [{
    "_id": ObjectId("yyy"), // which is what I dont want
    "title": "ttt",
    "body": "bbbb",
  }]
}

如何让mongoose不在帖子内创建_id

0 个答案:

没有答案