[DOCS-14337] Map-Reduce Examples Docs Page - wrong or misleading examples Created: 06/Apr/21 Updated: 30/Oct/23 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual, Server |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Rita Martins Rodrigues (Inactive) | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Days since reply: | 1 year, 14 weeks, 2 days ago |
| Epic Link: | DOCSP-11701 |
| Description |
DescriptionOne of the freelancer writers that is writing an article for the SEO-Hygiene initiative (Content Marketing & Growth Teams) got stuck on writing some sample code examples with Node.js driver for the example of using MongoDB mapReduce.
For Context the thread of the email of the freelancer writer: At any rate, back to the issues with mapReduce; I attempted to run the following code: """ According to the Node driver's .d.ts files, this is valid usage. However, I got the error: """ So, looking back at the docs page, I saw that there was a string assigned to "out": """ Not only did I get errors from typescript saying that "out" needed to be an object, I got the same error as before. However, with some searching online, I found that you're able to change the last config object to: """ Once I did this, I got an array of values, without commas, not combined in any way, returned to the console. Code: """ Output (shortened): """ Not knowing how Array.sum works (it's not valid JS, but it's documented as the way to combine an array of numbers from the docs page), I decided to use `values.reduce` to manually add the numbers together: """ However, I ended up just getting `0` as a string appended at the start """ I then decided to try and get the value of `NumberDecimal`. I tried using `parseInt` on `c`, which left me with `0` as a final result. I assume this is because `parseInt(Object)` is `NaN` The only way I was able to get the results of the numbers combined was the following code: """ However, this seems like an obvious anti-pattern and I wouldn't feel comfortable putting this as official docs that I wrote. Just to make sure this wasn't a bug in the NodeJS driver, I attempted to use the Mongo Shell: """ db.sales.mapReduce( And ran into the same issues as before (I tried all of the code variations I outlined for NodeJS as well with the same results)
Scope of changesImpact to Other DocsMVP (Work and Date)Resources (Scope or Design Docs, Invision, etc.) |
| Comments |
| Comment by Education Bot [ 31/Oct/22 ] |
|
Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you! |
| Comment by Rita Martins Rodrigues (Inactive) [ 06/Apr/21 ] |
|
To help on the triage: |