Open
Description
It states that it scans all fields that exist, but what I know is that $all checks if all specified array match on the field that is an array
{
--
_id: ObjectId("5234cc89687ea597eabee675"),
code: "xyz",
tags: [ "school", "book", "bag", "headphone", "appliance" ],
qty: [
{ size: "S", num: 10, color: "blue" },
{ size: "M", num: 45, color: "blue" },
{ size: "L", num: 100, color: "green" }
]
}
{ tags: { $all: [ "ssl" , "security" ] } }
the behavior will be like this
{ $and: [ { tags: "ssl" }, { tags: "security" } ] }
But in laravel docs does mongodb $all has another behavior that check each fields( like $exist but in one go without loop)
{ "title": "Cosmos",
"year": 1980,
"runtime": 60,
"imdb": {
"rating": 9.3,
"votes": 17174,
"id": 81846
},
},
//Is this correct, or does mongodb $all has another behavior that check each fields( like $exist but in one go without loop)
$result = DB::table('movies')
->where('movies', 'all', ['title', 'rated', 'imdb.rating'])
->get();
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-][Feature Request] Clarify Docs about all[/-][+]Clarify Docs about all[/+]GromNaN commentedon Feb 27, 2025
You're right, the
all
operator is just the$all
. The description should be identical between the Laravel-MongoDB doc and the operator doc.The tests show that:
laravel-mongodb/tests/Query/BuilderTest.php
Lines 429 to 452 in 0a80c70
Internally tracked for review by the docs team: DOCSP-47950