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
}
mongooseにカスタムの読み込まれたビューを構築せずに参照モデルの詳細を表示する方法はありますか?
あなたは "移入" のようなものを意味ですか? – Zlatko
はい、これに似ていますが、このためのカスタムビューを作成していない – abolotnov
私の頭の上から考えることができる唯一の方法は、実際には余分なドキュメントをモデルに入れ子にすることです。そして、アプリでアップデート戦略を見つけてください。 – Zlatko