0
我有在它REF域的模式:通過mongoose REST顯示引用文檔的詳細信息?
exports.metricSchema = new Schema({
metricGroup: {type: mongoose.Schema.Types.ObjectId, ref: 'metricGroupSchema', required: true},
metricType: {type: mongoose.Schema.Types.ObjectId, ref: 'metricTypeSchema', required: true},
key: {unique: true, type: String, required: true},
name: {type: String, required: true},
description: String
});
我定義並把它們註冊爲:
var MetricGroupResource = apprest.resource = restful.model('MetricGroup', schemas.metricGroupSchema)
.methods(defaultRestMethods);
MetricGroupResource.register(apprest, '/rest/metricgroup');
,它會在貓鼬REST顯示爲這樣:
{
"_id": "58a20f5f04ef5789d3ef8fb7",
"name": "Tangle Index",
"key": "TI",
"metricType": "58a20f43f1bbfe89c86bf602",
"metricGroup": "58a20f43f1bbfe89c86bf600",
"__v": 0
}
有沒有方法讓貓鼬在不構建自定義填充視圖的情況下顯示引用模型的詳細信息?
你的意思是像 「填充」? – Zlatko
是的,與此類似,但沒有爲這個 – abolotnov
創建自定義視圖那麼,我能想到的唯一辦法就是將這些額外的文檔嵌入到您的模型中。然後找出應用程序中的更新策略。 – Zlatko