npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

datda

v0.0.1

Published

MongoDB <--> RethinkDB : Import databases between MongoDB and RethinkDB.

Downloads

3

Readme

datda

Import databases between MongoDB and RethinkDB.

This module helps you easily import MongoDB database into RethinkDB and back. The implementation is very simple. datda merely gets all the collecitons/tables in your database and gets all the documents/rows in that collectiont/table and inserts them into the other database. The beauty of JSON document stores.

Install

To use the CLI:

npm install -g datda

To use in your node app:

npm install datda

API

CLI

datda
  --m2r                        // Set MongoDB as the source database and RethinkDB as the target database. Overwrites `source` and `target`.
  --r2m                        // Set RethinkDB as the source database and MongoDB as the target database. Overwrites `source` and `target`.

  --source [mongodb/rethinkdb] // Specify whether to import from MongoDB to RethinkDB or from RethinkDB to Mongo (Default: `mongo`)
  --target [mongodb/rethinkdb] // Specify whether to import to MongoDB to RethinkDB or from RethinkDB to Mongo (Default: `rethinkdb`)

  --db                         // Name of database (Can be overwritten by `rdb_db` and `mongo_db`)

  --mdb_db name_of_database
  --mdb_host host              // (Default: 27017)
  --mdb_port mongoport         // (Defulat: ‘localhost’)

  --rdb_db_ name_of_database
  --rdb_port port_number       // (Default: 28015)
  --rdb_host host              // (Default: ‘localhost’)

  --rows_per_batch             // Number of documents/rows per insert query (Default: 1000)
  --log                        // Wheter to log out important events and progress (Default: false)

Examples

Importing the hello database from MongoDB into RethinkDB

datda --m2r --db hello

Importing the hello_mongo database from MongoDB into a database called hello_rethinkb in RethinkDB.

datda --m2r --mdb_db hello_mongo --rdb_db hello_rethinkdb

Importing the hello database from a remote RethinkDB instance into a local MongoDB instance.

datda --r2m --mdb_host 123.123.123.123 --db hello

Node.js

var datda = require('mtr');

datda({
  source: 'mongodb',
  target: 'rethinkdb',
  mongo: {
    host: 'localhost',
    port: 8080,
    db: ‘db’
  },
  rethinkdb: {
    host: 'localhost',
    port: 28015,
    db: 'db'
  }
})
.then(function (importLog) {
  // Import log object
});

Examples

Importing the hello database from MongoDB into RethinkDB

datda({
  db: 'hello'
})
.then(function() { });

Importing the hello_mongo database from MongoDB into a database called hello_rethinkb in RethinkDB.

datda({
  mongodb: {
    db: 'hello_mongo'
  },
  rethinkdb: {
    db: 'hello_rethinkdb'
  }
})
.then(function() { });

Importing the hello database from a remote RethinkDB instance into a local MongoDB instance.

datda({
  source: 'rethinkdb',
  target: 'mongodb',
  db: 'hello',
  mongodb: {
    host: '123.123.123.123'
  },
  rethinkdb: {
    db: 'hello_rethinkdb'
  }
})
.then(function() { });

FAQs

Will my data get overwritten if the database already exists?

No. datda expects your source database to exist and your target database not to exist. It will created the database automatically.

Will primary indexes get imported as primary indexes?

Yes. datda imports the primary index from and to the database. If the source database is MongoDB, it will import the _id into id, deleting a preexisting id property. If RethinkDB is the source database, it will import whatever the primaryIndex is in that table into the _id property in MongoDB, deleting anything previously in the _id property.

Will secondary indexes get imported?

No. Importing secondary indexes is not supported.