[SERVER-6464] should $ifNull accept [] as null? Created: 16/Jul/12 Updated: 26/Jul/13 Resolved: 16/Sep/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Matt Dannenberg | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Comments |
| Comment by Ivan Hristov [ 26/Jul/13 ] |
|
what would be nice is to have $ifNullOrEmpty operator |
| Comment by Eliot Horowitz (Inactive) [ 16/Sep/12 ] |
|
[] is not null |
| Comment by Matt Dannenberg [ 16/Jul/12 ] |
|
The main reason I think it might be useful is when you $unwind a field that has an empty array you get no resulting documents. Currently as a workaround you'd have to do two $projects: one with an $ifNull on the field and a $cond where you check to see if the field is $eq to []. In both cases give an array with a throwaway value in it. If $ifNull accepted [] as null, then only one of these pipeline elements would be needed. This is useful for cases where you need to collect all values of a top level field and all values of a nested field in an array of objects where the array may be empty. |
| Comment by Andy Schwerin [ 16/Jul/12 ] |
|
In javascript, [] is not null. I'm inclined to say that's the way we want it, but can you provide some context in the description? |