用populate的mongoose自定义id?

时间:2017-02-24 13:17:32

标签: node.js mongodb mongoose mongoose-populate

如何使用populate通过自定义object_id选择对象,所以我得到了

 const BookSchema = new mongoose.Schema({
    title: {
        type: String
    },
    description: {
        type: String
    }
    });
    module.exports = mongoose.model('Book', BookSchema)

并且有一个翻译集

const TranslationSchema = new mongoose.Schema({
uuid:{
    type:String,
    required: true,
    index: true
},
locale: {
    type: String,
    trim: true,
    required: true,
    index: true
},
translation: {
    type: String,
    default:''
}
});

module.exports = mongoose.model('Translation', TranslationSchema);

现在预订标题和描述有一个代表翻译的UUID,我想制作.populate('title')并将标题作为UUID和locale传递给字符串让我们说“en”它是否可能?

0 个答案:

没有答案