Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does mongo update a field to the value of another field?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

这篇文章主要介绍"mongo怎么更新字段为另一字段的值",在日常操作中,相信很多人在mongo怎么更新字段为另一字段的值问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"mongo怎么更新字段为另一字段的值"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

db.postMongo.find(过滤条件).forEach(

function(item){

db.postMongo.update({"_id":item._id},{"$set":{"summary":item.content}},false,true)

}

)

db.postMongo.find({'summary':{$exists:false},'content':{$exists:1} }).forEach( function(item){ db.postMongo.update({"_id":item._id},{"$set":{"summary":item.content}},false,true) })到此,关于"mongo怎么更新字段为另一字段的值"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report