datacamp-logo

"...it's the life in your years"

For the pipeline we developed in the last slide deck, I want you to replace the last ($bucket) stage with one such that, given the documents docs collected, we can get the following output:

from operator import itemgetter

print(max(docs, key=itemgetter("years")))
print(min(docs, key=itemgetter("years")))
{'firstname': 'Rita', 'surname': 'Levi-Montalcini', 'years': 103.0}
{'firstname': 'Martin Luther', 'surname': 'King Jr.', 'years': 39.0}

You may assume that any earlier $project stage has been replaced by an equivalent $addFields stage.

Answer the question
50 XP
Possible Answers
  • press
  • press
  • press
  • press