mongoDB mongoimport upsert [英] mongoDB mongoimport upsert

查看:253
本文介绍了mongoDB mongoimport upsert的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下内容进行批量更新

I'm trying to do a bulk update with the following

mongoimport -d my_db -c db_collection -upsertFields email ~/Desktop/update_list.csv

我要导入的csv看起来像这样.

the csv that i'm trying to import looks like this.

email, full_name
stack@overflow.com,stackoverflow
mongo@db.com,mongodb

它应将电子邮件列作为查询arg进行检查,并相应地更新全名.但是,没有导入任何文件,它遇到了错误.

It should check the email column as a query arg and update the full name accordingly. However, none were imported, it encountered errors.

exception:Failure parsing JSON string near: abc@sa
abc@sasa.com,abc
imported 0 objects
encountered 99398 errors

问题出在哪里?我应该怎么做?

Where is the problem? How should i be doing it?

推荐答案

您的mongoimport命令缺少--upsert选项,该选项与--upsertFields结合使用.试试:

Your mongoimport command is missing the --upsert option, which is needed in combination with --upsertFields. Try:

mongoimport -d my_db -c db_collection --upsert --upsertFields email ~/Desktop/update_list.csv

这篇关于mongoDB mongoimport upsert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆