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 trialArtur Veselovski
6,138 PointsMongo/mongoose update operation speed
I have a simple question regarding performance and best practice of updating single documents.
If I have an array of documents, and each document has many fields (10 to 20) with some of the fields being arrays or objects... And I have an action in my app that frequently updates one single field in one document, say "isChecked": Boolean.
Is there a significant performance gain to make a separate route handler that updates that one field:
SomeModel.update( { _id: userId, 'documents._id': documentId }, { 'documents.$.isChecked: newVal }, function (err, res) { ... } );
Versus simply updating the whole document at once by supplying the document object from front app instead of one value?