【发布时间】:2019-11-24 05:48:07
【问题描述】:
我是 Mongo 的新手。请帮助确定数据结构。我有分支,每个分支都有名称和屏幕数,每个分支都可以有很多播放列表,每个播放列表都有名称、开始日期、结束日期、总时间和文件。我需要告诉每个文件在哪个屏幕上它应该以什么顺序和它的显示时间。我想在具有不同属性的不同播放列表中使用文件
const FileSchema = Schema({
url: {
type: String,
required: true
},
showTime: {
type: Date,
required: true
},
screen: {
type: Number,
required: true
},
order: {
type: Number,
required: true
},
}, {
timestamps: true
});
const PlaylistSchema = Schema({
name: {
type: String,
required: true
},
endDate: {
type: Date,
required: true
},
files: [FileSchema]
}, {
timestamps: true
});
const BranchSchema = Schema({
name: {
type: String,
required: true
},
screens: {
type: Number,
required: true
},
playlists: [Playlists]
}, {
timestamps: true
});
【问题讨论】:
-
看到mongo接受json结构,所以你只需要弄清楚你已经拥有的模型,现在用你选择的后端语言创建模型类,选择一个ORM层然后推送模型到 mongo 服务器。
-
我明白了。我需要知道我的数据结构是否正确。
-
您能描述一下您有哪些不同的数据访问模式吗?您对当前模型有什么担忧?
-
我想知道好不好。
-
你能不能好心地举一个你的数据结构的 JSON 示例?
标签: database mongodb mongoose data-structures mongoose-schema