mongodb - How to do multiple aggregation operations in MongoQuery and Update the field in a collection -


in rdbms, suppose have 4 columns , col1, col2, col3, col4

if want col4 value col1 + col2 - col3, can write update statement follows:

update table set col4=col1+col2-col3 

is doing multiple operations possibe using mongo shell aggregation?

i tried sum of 2 fields using aggregation following query.

db.students.aggregate([         {               $project: { examtotal: { $add: [ "$final", "$midterm" ] } }     },     { $out: "students" } ]) 

but query replacing fields in same collection. how achieved?

col4=col1+col2-col3 , update col4 value in same collection. can possible within single step?


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -