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

查看:39
本文介绍了使用 mongoimport 导入 1 个以上的 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 导入 1 个以上的 json 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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