- 
  Notifications
 You must be signed in to change notification settings 
- Fork 1.4k
[Question] Query object of object inside an array #2320
-
- Laravel-mongodb Version: 3.7.x
- PHP Version: 7.4
- Database Driver & Version:
The contact collection:
[ { _id:1, "phones": [ { "label": "Home", "country": { "name": "Singapore", "dial_code": "+60", "code": "SG" }, "value": "xxxxx", "_default": true, "whatsapp": true }, { "label": "Personal", "country": { "name": "Singapore", "dial_code": "+60", "code": "SG" }, "value": "xxxxx", "_default": true, "whatsapp": true } ] }, { _id:2, "phones": [ { "label": "Home", "country": { "name": "Malaysia", "dial_code": "+60", "code": "MY" }, "value": "xxxxx", "_default": true, "whatsapp": true } ] } ]
If there a way to convert this db.contact.find({'phones':{$elemMatch:{'country.code':'MY'}}})
I tried contact_search::whereRaw(['phones'=>['$elemMatch'=>['country.code'=>'MY']]]) and it doesn't work. Thanks
Beta Was this translation helpful? Give feedback.