Match on null array item
See original GitHub issueImagine you have the following document in the collection Game:
{
cells: [ null, null, { value: 'x' }, null ]
}
With Mongo syntax you can perform queries like: get documents where cell[1] is null It would look like:
db.getCollection('Game').find({'cells.1': { $type: 10 }})
For reference: https://docs.mongodb.com/manual/tutorial/query-for-null-fields/
Unfortunately if we write in C#:
db.Find().Match(g => g.Cells[1] == null)
I believe that it gets translated to:
db.getCollection('Game').find({'cells.1': null})
Which will match any game document…
Is there a way to write the correct query? or at least to pass it as a raw string?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Match if array !contains or is null in Karate
Any advice to write a match that is true also when the array is null? Thanks. karate · Share.
Read more >Make .match() return an empty array instead of null when 0 ...
My suggestion is to return an empty array instead of null when no matches are found. This way, no extra case has to...
Read more >Managing null array - Power Platform Community - Microsoft
I want to go through and build a table of items for each person and email it out. I have built the majority...
Read more >Application.Match to find first Empty element in an array
1) Simplest solution is to loop through the array. 2) Match gives the position in an array or range counting from 1 regardless...
Read more >4 Ways to Check If an Array is Empty in Power Automate
This post is going to show you how to test for an array with no elements in ... Set the condition type to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yep all done. pushed v13.2.1 to nuget. might take a few minutes to show up. thanks for the PR.
actually nevermind the above. just figured out an easy way to combine filters. i’ll add the ability to call match multiple times as a breaking change. though i doubt it would break much as 95% users are already aware of the current behavior and they probably don’t have multiple match statements in their code.