I have a users collection like this,
{
"type": "provider",
"name": "user name",
"username": "username",
"password": "$2y$10$D3z0tLwOwB0tqPEnl63VuexOwqcR75QkVILemB1.TEsAJlk6Ixwim",
"specialties": [
"specialty 1",
"specialty 2"
]
}
and a specialties collection like below,
{
"_id": "5b26103b2df243228c0003ea",
"title": "specialty 1",
"description": "specialti 1 desc",
},{
"_id": "5b26103b2df243228c0003ea",
"title": "specialty 2",
"description": "specialti 2 desc",
},
The relation between them are embedded many and here is my relationship in User model,
public function specialties()
{
return $this->embedsMany(Specialty::class, 'specialties', 'title');
}
I want to get the users
who have a specialty that I want, I the above JSON It could be a user with a specialty like "specialty 1". I know about non-embedded collections but my data saved on my DB and I could not change the structure.
Is there any solution for this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire