【发布时间】:2018-11-27 11:04:39
【问题描述】:
我有以下 用户 集合:
{
"type": "provider",
"name": "user name",
"username": "username",
"password": "$2y$10$D3z0tLwOwB0tqPEnl63VuexOwqcR75QkVILemB1.TEsAJlk6Ixwim",
"specialties": [
"specialty 1",
"specialty 2"
]
}
还有一个特色菜系列:
{
"_id": "5b26103b2df243228c0003ea",
"title": "specialty 1",
"description": "specialti 1 desc",
},{
"_id": "5b26103b2df243228c0003ea",
"title": "specialty 2",
"description": "specialti 2 desc",
},
它们之间的关系是嵌入式的,这是我在用户模型中的关系,
public function specialties()
{
return $this->embedsMany(Specialty::class, 'specialties', 'title');
}
我想按专业过滤users。例如,如果过滤后的专业为“专业 1”,则应返回上述 JSON 用户对象。
我知道非嵌入式集合,但我的数据保存在我的数据库中,我不能不更改架构。
有其他解决方案吗?
【问题讨论】:
标签: database mongodb laravel-5