question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Match on null array item

See original GitHub issue

Imagine 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:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dj-nitehawkcommented, Jun 30, 2020

yep all done. pushed v13.2.1 to nuget. might take a few minutes to show up. thanks for the PR.

1reaction
dj-nitehawkcommented, Jun 30, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found