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

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -