mongoose.js 3:如何判断nested不是文档

mongoose.js 3:如何判断nested不是文档,mongoose,Mongoose,我的猫鼬模式: mongoose.Schema({ title: 'string', items: [{ uid: 'string', type: {type: 'string'}, title: 'string', items: [{uid: 'string', type: {type: 'string'}, text: 'string'}] }]

我的猫鼬模式:

mongoose.Schema({
        title: 'string',
        items: [{
            uid: 'string',
            type: {type: 'string'},
            title: 'string',
            items: [{uid: 'string', type: {type: 'string'}, text: 'string'}]
        }]
    });
如何告诉mongoose项和项的项不是文档,而是嵌套对象?我既不需要_id属性,也不需要它们的任何文档功能,但我想定义它们并用模式进行限制


id:false就足够了吗?

嵌入的文档数组如果没有您上面显示的自己的模式,那么它们将始终有一个id字段。如果要禁止使用{u-id,则它们必须有自己的模式,并且需要在其模式定义上设置{u-id:false}

猫鼬模式{ 标题:“字符串”, items:[mongoose.Schema{ uid:'字符串', 类型:{type:'string'}, 标题:“字符串”, items:[mongoose.Schema{ uid:'字符串', 类型:{type:'string'}, 文本:“字符串” },{u id:false}] },{u id:false}] };
没有自己的模式(如上面所示)的嵌入式文档数组将始终有一个_id字段。如果要禁止使用{u-id,则它们必须有自己的模式,并且需要在其模式定义上设置{u-id:false}

猫鼬模式{ 标题:“字符串”, items:[mongoose.Schema{ uid:'字符串', 类型:{type:'string'}, 标题:“字符串”, items:[mongoose.Schema{ uid:'字符串', 类型:{type:'string'}, 文本:“字符串” },{u id:false}] },{u id:false}] };