防止_id仅由一个模式填充

A. *_*Lau 8 mongoose mongodb

所以我有以下架构:

var List = new Schema(
    {
        item_details_template: {
            default: [
                {
                    "title": "Name",
                    "content": "",
                    "hidden": false,
                    "order": 0,
                    "the_type": "text"
                },
                {
                    "title": "Price",
                    "content": "",
                    "hidden": false,
                    "order": 1,
                    "the_type": "text"
                },
                {
                    "title": "Company",
                    "content": "",
                    "hidden": false,
                    "order": 2,
                    "the_type": "text"
                }
            ],
            type: [Item_Detail]
        }
    }
)
Run Code Online (Sandbox Code Playgroud)

但是,我不希望只有这个架构(子文档)不创建_id字段.我该怎么做呢?我知道你可以改变原来的架构本身,但它正被其他架构使用,我想要_id填充它.

ben*_*ime 0

如果您只想抑制模式中_id的:item_detail_templateList

var List = new Schema(
    {
        item_details_template: {
            _id:false, // should supress _id property
            default: [
            ...
Run Code Online (Sandbox Code Playgroud)