【发布时间】:2019-06-01 20:55:40
【问题描述】:
我在医疗保健项目中关注 Mongo Schemas(被截断以隐藏项目敏感信息)。
let PatientSchema = mongoose.Schema({_id:String})
let PrescriptionSchema = mongoose.Schema({_id:String, patient: { type: Number, ref: 'Patient', createdAt:Date }})
let ReportSchema = mongoose.Schema({_id:String, patient: { type: Number, ref: 'Patient', createdAt:Date }})
let EventsSchema = mongoose.Schema({_id:String, patient: { type: Number, ref: 'Patient', createdAt:Date }})
移动和网络应用程序有一个名为“健康历史”的 UI 屏幕,我需要在其中对基于 createAt 排序的处方、报告和事件中的条目进行分页。所以我正在构建一个 REST 端点来获取这些异构数据。我如何做到这一点。是否可以从多个模式模型创建“视图”,这样我就不会加载所有 3 个模式的内容来获取一页条目。我的“视图”的架构应该如下所示,以便我可以在其上运行其他查询(例如查找最后一个报告)
{recordType:String,/* prescription/report/event */, createdDate:Date, data:Object/* content from any of the 3 tables*/}
【问题讨论】:
标签: node.js mongodb mongoose mongodb-query aggregation-framework