[DOCS-10675] [Server] Revision on arrayToObject Created: 14/Aug/17 Updated: 30/Oct/23 Resolved: 30/Nov/22 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual, Server |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | David Hou |
| Resolution: | Done | Votes: | 0 |
| Labels: | collector-298ba4e7, docs-triage, reopened | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: | |||
| Participants: | |
| Days since reply: | 1 year, 8 weeks, 2 days ago |
| Epic Link: | DOCSP-11701 |
| Description |
|
Instead of using $literal in the two example, just wrap the array in another array. Use a field expression instead of fixed values to show that it's possible (and that can't be done with $literal) |
| Comments |
| Comment by Githook User [ 12/Dec/22 ] | ||
|
Author: {'name': 'davidhou17', 'email': '55004296+davidhou17@users.noreply.github.com', 'username': 'davidhou17'}Message: (
| ||
| Comment by Githook User [ 01/Dec/22 ] | ||
|
Author: {'name': 'davidhou17', 'email': '55004296+davidhou17@users.noreply.github.com', 'username': 'davidhou17'}Message: (
| ||
| Comment by Githook User [ 01/Dec/22 ] | ||
|
Author: {'name': 'davidhou17', 'email': '55004296+davidhou17@users.noreply.github.com', 'username': 'davidhou17'}Message: (
| ||
| Comment by Githook User [ 01/Dec/22 ] | ||
|
Author: {'name': 'davidhou17', 'email': '55004296+davidhou17@users.noreply.github.com', 'username': 'davidhou17'}Message: (
| ||
| Comment by Githook User [ 01/Dec/22 ] | ||
|
Author: {'name': 'davidhou17', 'email': '55004296+davidhou17@users.noreply.github.com', 'username': 'davidhou17'}Message: (
| ||
| Comment by Githook User [ 30/Nov/22 ] | ||
|
Author: {'name': 'davidhou17', 'email': '55004296+davidhou17@users.noreply.github.com', 'username': 'davidhou17'}Message: (
| ||
| Comment by Asya Kamsky [ 01/Nov/22 ] | ||
|
more specifically, using `$literal` is only useful when you have literal values you want to convert. However, usually the user will be converting fields and expressions using field values and that means they cannot use `$literal` so having every example only show how to do this with literal (aka constant) fields is not very useful! | ||
| Comment by Sarah Olson [ 31/Oct/22 ] | ||
|
Have reviewed with asya.kamsky@mongodb.com. Her request is more user facing and solves for the question about whether a user wants to use a literal or no. | ||
| Comment by Asya Kamsky [ 14/Aug/17 ] | ||
|
Also, should add a note about what happens if the same field name ("k" value) appears more than once in the array - the first value ("v" value) wins. edit this part was already done. | ||
| Comment by Asya Kamsky [ 14/Aug/17 ] | ||
should just be
The reason you need second set of [ ] is because it tells arrayToObject there inside it are its arguments. If they are missing, it will interpret inner array [ ] and give an error that it got two arguments when it expected one. $literal only works when everything is literal but if, say, 25 was coming from another field then you couldn't use $literal and would have to use [ ]. |