如何将我的 MongoDB 迁移到 RethinkDB?

How can I migrate my MongoDB to RethinkDB?

如何将我的 MongoDB 集合迁移到 RethinkDB 表?

我不担心将旧的 Mongo _id 更改为 Rethink id,因为它们会在我的实施中被忽略,我不担心关于他们弄乱我的数据。

我写了一个快速 BASH 脚本来解决这个问题。因为我只有 JavaScript RethinkDB 驱动程序,所以我必须先 install the python driver 才能使用 rethinkdb import

对于此示例,我正在迁移 mongo collections:userspinboardsanalytics;根据需要将 collections 添加到以下 BASH 命令中:

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

不要忘记更改您的collections、主机和数据库的名称。此外,根据需要将参数调整为 mongoexport and rethinkdb import

这是快速而肮脏的,但我希望它能让某人朝着正确的方向开始!