简体   繁体   中英

$addField query does not work as expected

I am running this query to add new field in my document, and it run successfully but does not update the document in mongodb.(movies is the collection name, mongodb version - 4.2.15 Community)

db.movies.aggregate([{
 $addFields: {
   totalHomework: "123312" ,
   totalQuiz: "12312"
 }}])

update

db.collection.update({},
{
  $set: {
    totalHomework: "123312",
    totalQuiz: "12312"
  }
})

mongoplayground

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM