Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Question] Query object of object inside an array #2320

Unanswered
adhasahar97 asked this question in Q&A
Discussion options

  • 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

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #2319 on October 04, 2021 09:09.

AltStyle によって変換されたページ (->オリジナル) /