How can I migrate my MongoDB to RethinkDB?

瘦欲@ 提交于 2019-12-05 00:10:16

问题


How can I migrate my MongoDB collections to RethinkDB tables?

I'm not concerned about changing my old Mongo _id's to Rethink id's because they will be ignored in my implementation, and I'm not concerned about them cluttering my data.


回答1:


I wrote a quick BASH script to solve this. Because I only had the JavaScript RethinkDB driver, I had to install the python driver first so I could use rethinkdb import.

For this example, I am migrating the mongo collections: users, pinboards, and analytics; add your collections as needed to the following BASH command:

for collection in users pinboards analytics; \
do \
  mongoexport \
    --host my.mongo.server \
    --db my_mongo_database \
    --collection $collection \
  > $collection.json; \
  rethinkdb import \
    --file $collection.json \
    --table my_rethink_database.$collection; \
  rm $collection.json; \
done

Don't forget to change the names of your collections, host, and database. Also, adjust arguments to mongoexport and rethinkdb import as needed.

This is quick and dirty, but I hope it gets someone started in the right direction!



来源:https://stackoverflow.com/questions/29240655/how-can-i-migrate-my-mongodb-to-rethinkdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!