使用mongoimport导入多个json文件 [英] Import more than 1 json file using mongoimport

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

问题描述

我是mongodb的新手,想了解有关将json文件从一台服务器导入到另一台服务器的信息.我尝试了以下命令mongoimport -d test -c bik check.json,它对我来说很好用.现在,我想知道当有多个json文件时,如何一次导入所有这些文件.我找不到任何相关的书面文件,这是不可能的.请帮助我,这有可能吗?

I am new to mongodb and want to know about importing a json file from one server to another. I tried the following command mongoimport -d test -c bik check.json and it works fine for me. Now i want to know when there are multiple json files how do i import all of them at a single go. I could not find any related document where it is written this is not possible. Please help me is this possible and how

推荐答案

您始终可以编写一些shell脚本.

You can always write some shell scripts.

colls=( mycoll1 mycoll2 mycoll5 )

for c in ${colls[@]}
do
  mongoimport -d mydb -c $c.json
done

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

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