mongoose填充(populate)
mongoose填充(populate)
用法
基础用法
export const CommentSchema = new mongoose.Schema(
{
author: {
ref: 'user_info',
type: mongoose.Types.ObjectId,
},
},
);
export const commentModel = mongoose.model('comments', CommentSchema);只填充特定字段
匹配规则
填充多个字段
填充数组
判断是否已填充及取消填充
限制填充总数和限制每文档填充数
参考
最后更新于