Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMohammad Muneeb
1,994 PointsIsnβt supposed to be $set ????
This should be $set operator
2 Answers
Steven Parker
231,248 PointsI'm guessing you're on the question that asks:
The second parameter of the
update
method is the ___________ parameter.
The "update" method takes 3 parameters, which are: "query", "update", and "options". The correct answer is one of those.
Hakim Rachidi
38,490 PointsHi Mohammad
You somewhat right: we often use the $set operator for simple update operations, but inside the second parameter of update
the $set
operator is only one of many.
Just to name a few:
-
$currentDate
(sets field to the current date) -
$inc
(increments a field the specified number) -
$mul
(multiplies a number by a given number) - ...
All these operators and more can go into the update parameter (even multiple) like so:
db.cats.update({}, {$currentDate: {feededAt: true}, $inc: {age: 1}});