Mongoose select:false一个ObjectIds数组

phi*_*wei 4 mongoose

我试图做的非常类似的东西这个,但我不想直接引用子对象的架构.我正在使用ObjectId和Ref表示法:

children: [{ type: mongoose.Schema.Types.ObjectId, ref: 'SomeSchema' }]
Run Code Online (Sandbox Code Playgroud)

反正有没有实现这个目标?我在文档中没有看到任何内容.

phi*_*wei 13

回想起来,这应该是显而易见的:

children: { 
    type: [{ type: mongoose.Schema.Types.ObjectId, ref: 'SomeSchema'}],  
    select: false 
} 
Run Code Online (Sandbox Code Playgroud)