从Windows文件夹使用mongoimport批量导入MongoDB [英] MongoDB Bulk import using mongoimport from Windows folder

查看:585
本文介绍了从Windows文件夹使用mongoimport批量导入MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的存档中有很多json文件,我需要通过一项操作将它们导入mongo(我认为这可能是循环的).您对此有任何想法吗?

I have a lot of json files in archive and i need to import them into mongo per one operation (i think that it might be in cycle). Have you any ideas about this?

推荐答案

如果您使用的是Linux/Unix shell,则可以尝试

If you are in a Linux/Unix shell you can try

for filename in *; do mongoimport -d mydb -c $filename;  done

如果您使用的是Windows:

If you are on Windows:

FOR %i IN (C:\mongodbData\*.json) DO mongoimport --db dbName --collection colection --type json --file %i

这篇关于从Windows文件夹使用mongoimport批量导入MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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