我正在学习MongoDB,我需要模式设计建议。
所以,我有几个城市的祈祷时间。我为34个省中的一个省做了一份文件。
这是一个省的例子:
{
name: "Province A",
slug: "province-a",
cities: [
{
name: 'City A',
slug: 'city-a',
latitude: `4° 09' 31.76" N`,
longtitude: `96° 07' 28.86" E`
times: {
"2021": {
"1": {
"1": {
date: 'Friday, 01/01/2021',
imsak: '05:11',
subuh: '05:21',
terbit: '06:39',
dhuha: '07:08',
dzuhur: '12:42',
ashar: '16:05',
maghrib: '18:39',
isya: '19:53'
},
"2": {
date: 'Saturday, 02/01/2021',
imsak: '05:11',
subuh: '05:21',
terbit: '06:39',
dhuha: '07:08',
dzuhur: '12:42',
ashar: '16:05',
maghrib: '18:39',
isya: '19:53'
},
// other date ...
},
// other month ...
},
// other year (2021 - 2030) ...
}
},
// other city
]
}这是很好的实践吗?
如果不是,您能提供像我这样的数据的最佳实践示例吗?
谢谢你,我真的很感激你的回答。
发布于 2021-12-03 14:05:33
不,我不认为将所有文档都放在raccomandations模式中是最好的做法,而只是reccommended的_id。
下面是一个如何保存数据以供推荐的示例(模式的文档底部为scrool):https://www.npmjs.com/package/mongoose-recommended-plugin
https://stackoverflow.com/questions/70213571
复制相似问题