[DOCS-1152] Unclear how to use $cond and $ifnull aggregation operators Created: 22/Feb/13 Updated: 26/Sep/13 Resolved: 25/Sep/13 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Daniel Gottlieb (Inactive) | Assignee: | Zack Brown |
| Resolution: | Done | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Days since reply: | 10 years, 20 weeks, 6 days ago |
| Description |
|
http://docs.mongodb.org/manual/reference/aggregation/#conditional-expressions The documentation refers to "boolean-expression", "true-case", "false-case" for $cond and "expression", "replacement-if-null" for $ifNull. Are these types strings that contain javascript expressions? Are document elements usable as inputs? If documents being aggregated on are not available, what can this be used for? A non-trivial example usage would definitely go a long way. |
| Comments |
| Comment by auto [ 26/Sep/13 ] | |||
|
Author: {u'username': u'Zackrobat', u'name': u'Zack Brown', u'email': u'zack.brown@10gen.com'}Message: Signed-off-by: Sam Kleinman <samk@10gen.com> | |||
| Comment by Jochen Kemnade [ 24/Jul/13 ] | |||
|
I'm currently trying to combine $cond with $project. I want to transform non-array values into arrays, so my expression looks something like
From my experiments, I can tell that boolean-expression, true-case and false-case are actual expressions, not strings:
works like one would expect. |