You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by garrensmith <gi...@git.apache.org> on 2015/12/02 14:33:42 UTC

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

GitHub user garrensmith opened a pull request:

    https://github.com/apache/couchdb-nmo/pull/16

    Import mongo collections into CouchDB

    New command `import-mongo` which imports a mongo collection into a
    database.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/garrensmith/couchdb-nmo mongo-import

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-nmo/pull/16.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16
    
----
commit bbc527e8e4e5a8e6bfdb519013878e2d69ef007b
Author: Garren Smith <ga...@gmail.com>
Date:   2015-11-30T12:41:34Z

    Import mongo collections into CouchDB
    
    New command `import-mongo` which imports a mongo collection into a
    database.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46426977
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,63 @@
    +import fs from 'fs';
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo [clustername] [database] [MongoDB-url] [collection]',
    +      'nmo import-mongo [url] [database] [MongoDB-url] [collection]'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (cluster, database, mongourl, collection) {
    +  return new Promise((resolve, reject) => {
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching - ' + err.message;
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error converting - ' + err.message;
    --- End diff --
    
    db.close(); missing in the upper two cases, but maybe not so important as the command finishes anyway with process.exit afterwards


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-162832774
  
    what means:
    
    ```
    (10:43:39) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo anemone restaurants mongodb://localhost:27017/test restaurants
    ERR! Error fetching collection - server localhost:27017 sockets closed
    ERR! MongoError: Error fetching collection - server localhost:27017 sockets closed
    ERR!     at Server.destroy (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:676:47)
    ERR!     at Server.close (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/server.js:371:17)
    ERR!     at Db.close (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/db.js:335:19)
    ERR!     at CouchBulkImporter.<anonymous> (/Users/robert/apache/couchdb-nmo/lib/import-mongo.js:68:12)
    ERR!     at emitOne (events.js:82:20)
    ERR!     at CouchBulkImporter.emit (events.js:169:7)
    ERR!     at onwriteError (_stream_writable.js:304:10)
    ERR!     at onwrite (_stream_writable.js:322:5)
    ERR!     at WritableState.onwrite (_stream_writable.js:89:5)
    ERR!     at CouchBulkImporter.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/index.js:47:16)
    ERR!     at Request.self.callback (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:368:22)
    ERR!     at emitTwo (events.js:87:13)
    ERR!     at Request.emit (events.js:172:7)
    ERR!     at Request.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:1219:14)
    ERR!     at emitOne (events.js:82:20)
    ERR!     at Request.emit (events.js:169:7)
    ERR!
    ERR!
    ERR! nmo: 1.1.0 node: v4.2.1
    ERR! please open an issue including this log on https://github.com/robertkowalski/nmo/issues
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49312276
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,74 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    --- End diff --
    
    Invalid MongoDB url - url must start with mongodb://


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46427475
  
    --- Diff: test/import-mongo.js ---
    @@ -0,0 +1,87 @@
    +import assert from 'assert';
    +import nock from 'nock';
    +import Lab from 'lab';
    +export const lab = Lab.script();
    +import { createConfigFile } from './common';
    +
    +import nmo from '../src/nmo.js';
    +import importmongo, { cli }  from '../src/import-mongo.js';
    +import mongo from 'mongodb';
    +import JSONStream from 'JSONStream';
    +
    +//mongodb mock
    +const mongoDocs = [{a: 1}, {b: 2}];
    +mongo.connect = function (url, cb) {
    +  const col = {
    +    find: function () {
    +      const stream = JSONStream.stringify();
    +      setTimeout(function () {
    +        stream.write(mongoDocs);
    +        stream.end();
    +      }, 10);
    +      return stream;
    +    }
    +  };
    +
    +  const db = {
    +    collection: function () {
    +      return col;
    +    }
    --- End diff --
    
    add a stub close method , i think that will fix the testsuite :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46426220
  
    --- Diff: doc/cli/nmo-import-mongo.md ---
    @@ -0,0 +1,24 @@
    +nmo-import-mongo(1) -- Bulk import a MongoDB collection
    +===========================================
    +
    +## SYNOPSIS
    +
    +    nmo import-mongo [clustername] [database] [MongoDB-url] [collection]
    +    nmo import-mongo [url] [database] [MongoDB-url] [collection]
    --- End diff --
    
    i think those are all required arguments?
    
    (use `< >` instead of `[ ]`, the latter are to signal optional arguments)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49312456
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,74 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching collection - ' + err.message;
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error - ' + err.message;
    +          if (/CouchDB server answered/.test(err.message)) {
    +            err.type = 'EUSAGE';
    +          }
    +          reject(err);
    +        })
    +        .pipe(new CouchBulkImporter({
    +          url: clusterUrl + '/' + database
    +        }))
    +        .on('error', function (err) {
    +          err.message = 'Error migration incomplete - ' + err.message;
    --- End diff --
    
    when i mistype my cluster i get a stacktrace:
    
    ```
    (12:40:46) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo mongodb://127.0.0.1:27017 restaurants blerg blerg
    /Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/mongo_client.js:458
              throw err
              ^
    
    Error: Cluster does not exist
        at getClusterUrls (/Users/robert/apache/couchdb-nmo/lib/utils.js:119:15)
        at getUrlFromCluster (/Users/robert/apache/couchdb-nmo/lib/utils.js:113:10)
        at /Users/robert/apache/couchdb-nmo/lib/import-mongo.js:62:53
        at /Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/mongo_client.js:455:11
        at doNTCallback0 (node.js:417:9)
        at process._tickCallback (node.js:346:13)
    
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49312312
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,74 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    --- End diff --
    
    should be a usage error, i just got:
    
    ```
    (12:40:06) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo mongo://127.0.0.1:27017 restaurants blerg blerg
    ERR! Invalid MongoDB url
    ERR! Error: Invalid MongoDB url
    ERR!     at /Users/robert/apache/couchdb-nmo/lib/import-mongo.js:51:17
    ERR!     at Promise._execute (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/debuggability.js:159:9)
    ERR!     at Promise._resolveFromExecutor (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/promise.js:460:18)
    ERR!     at new Promise (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/promise.js:76:14)
    ERR!     at importmongo (/Users/robert/apache/couchdb-nmo/lib/import-mongo.js:49:10)
    ERR!     at cli (/Users/robert/apache/couchdb-nmo/lib/import-mongo.js:38:10)
    ERR!     at /Users/robert/apache/couchdb-nmo/bin/nmo-cli.js:34:6
    ERR!     at tryCatcher (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/util.js:11:23)
    ERR!     at Promise._settlePromiseFromHandler (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/promise.js:489:31)
    ERR!     at Promise._settlePromise (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/promise.js:546:18)
    ERR!     at Promise._settlePromise0 (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/promise.js:591:10)
    ERR!     at Promise._settlePromises (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/promise.js:674:18)
    ERR!     at Async._drainQueue (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/async.js:129:16)
    ERR!     at Async._drainQueues (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/async.js:139:10)
    ERR!     at Immediate.Async.drainQueues [as _onImmediate] (/Users/robert/apache/couchdb-nmo/node_modules/bluebird/js/release/async.js:16:14)
    ERR!     at processImmediate [as _immediateCallback] (timers.js:368:17)
    ERR!
    ERR!
    ERR! nmo: 1.1.0 node: v4.2.1
    ERR! please open an issue including this log on https://github.com/robertkowalski/nmo/issues
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49344762
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,74 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching collection - ' + err.message;
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error - ' + err.message;
    +          if (/CouchDB server answered/.test(err.message)) {
    +            err.type = 'EUSAGE';
    +          }
    +          reject(err);
    +        })
    +        .pipe(new CouchBulkImporter({
    +          url: clusterUrl + '/' + database
    +        }))
    +        .on('error', function (err) {
    +          err.message = 'Error migration incomplete - ' + err.message;
    +          reject(err);
    +        })
    +        .on('finish', function () {
    +          db.close();
    +          console.log('Migration complete!');
    +          resolve();
    --- End diff --
    
    I've fixed this to check for a collection count first. If there are 0 documents in the collection nmo now says this:
    
    `There are 0 documents in this collection. That could mean that the collection does not exist or that the database does not exist`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49312638
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,74 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching collection - ' + err.message;
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error - ' + err.message;
    +          if (/CouchDB server answered/.test(err.message)) {
    +            err.type = 'EUSAGE';
    +          }
    +          reject(err);
    +        })
    +        .pipe(new CouchBulkImporter({
    +          url: clusterUrl + '/' + database
    +        }))
    +        .on('error', function (err) {
    +          err.message = 'Error migration incomplete - ' + err.message;
    +          reject(err);
    +        })
    +        .on('finish', function () {
    +          db.close();
    +          console.log('Migration complete!');
    +          resolve();
    --- End diff --
    
    for not existing mongo databases it says:
    
    ```
    (12:44:34) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo mongodb://127.0.0.1:27017 restaurants12 anemone blerg
    Migration complete!
    ```
    
    but couchdb does not have any database created. this puzzles me. should we say to the user that we did not do any work?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith closed the pull request at:

    https://github.com/apache/couchdb-nmo/pull/16


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46427041
  
    --- Diff: test/import-mongo.js ---
    @@ -0,0 +1,87 @@
    +import assert from 'assert';
    +import nock from 'nock';
    +import Lab from 'lab';
    +export const lab = Lab.script();
    +import { createConfigFile } from './common';
    +
    +import nmo from '../src/nmo.js';
    +import importmongo, { cli }  from '../src/import-mongo.js';
    +import mongo from 'mongodb';
    +import JSONStream from 'JSONStream';
    +
    +//mongodb mock
    +const mongoDocs = [{a: 1}, {b: 2}];
    +mongo.connect = function (url, cb) {
    +  const col = {
    +    find: function () {
    +      const stream = JSONStream.stringify();
    +      setTimeout(function () {
    +        stream.write(mongoDocs);
    +        stream.end();
    +      }, 10);
    +      return stream;
    +    }
    +  };
    +
    +  const db = {
    +    collection: function () {
    +      return col;
    +    }
    +  };
    +
    +  cb(null, db);
    +};
    --- End diff --
    
    wow that's neat!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-162833487
  
    (it was thrown when my couchdb was in admin mode, but my cluster conf was in admin party) but i searched the error for 10min in my mongo setup


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49313027
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,74 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    --- End diff --
    
    the order is wrong here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-162833950
  
    general question:
    
    how would you like:
    
    ```
    nmo import-mongo mongodb://localhost:27017/test restaurants anemone restaurants 
    ```
    
    rational: i am importing a mongodb to my cluster


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46950456
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,79 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      err.type = 'EUSAGE';
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        err.type = 'EUSAGE';
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching collection - ' + err.message;
    +          db.close();
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error - ' + err.message;
    +          if (/CouchDB server answered/.test(err.message)) {
    +            err.type = 'EUSAGE';
    +          }
    --- End diff --
    
    looking at the trace maybe we are closing the db connection too early?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-170883531
  
    given that the error is probably an error with my cluster, +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r49312881
  
    --- Diff: doc/cli/nmo-import-mongo.md ---
    @@ -0,0 +1,24 @@
    +nmo-import-mongo(1) -- Bulk import a MongoDB collection
    +===========================================
    +
    +## SYNOPSIS
    +
    +    nmo import-mongo <MongoDB-url> <collection> <clustername> <database>
    +    nmo import-mongo <MongoDB-url> <collection> <url> <database>
    +
    +
    +## DESCRIPTION
    +
    +Import a MongoDB collection into CouchDB.
    +
    +Example:
    +
    +This will import the collection `restaurants` from the MongoDB url `mongodb://localhost:27017/test` into the database
    +`mydatabase` in the cluster `mycluster`.
    +
    +    nmo import-mongo mycluster mydatabase mongodb://localhost:27017/test restaurants
    +
    +This will import the collection `restaurants` from the MongoDB url `mongodb://localhost:27017/test` into the database
    +`mydatabase` at the url `http://127.0.0.1:15984`.
    +
    +    nmo import-mongo http://127.0.0.1:15984 mydatabase mongodb://localhost:27017/test restaurants
    --- End diff --
    
    the docs and the other help texts state two different usages:
    
    ```
    nmo import-mongo <MongoDB-url> <collection> <clustername> <database>
    ```
    
    vs
    
    ```
    nmo import-mongo http://127.0.0.1:15984 mydatabase mongodb://localhost:27017/test restaurants
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46949695
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,79 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      err.type = 'EUSAGE';
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        err.type = 'EUSAGE';
    --- End diff --
    
    no eusage here, this could be a broken mongo db?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46932313
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,65 @@
    +import fs from 'fs';
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    --- End diff --
    
    can we also test for a valid mongodb url, and add that to EUSAGE, so the driver does not bail with a long stacktrace if i forget it?
    
    ```
    (10:40:30) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo anemone restaurants foo restaurants
    ERR! invalid schema, expected mongodb
    ERR! Error: invalid schema, expected mongodb
    ERR!     at module.exports (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/url_parser.js:20:11)
    ERR!     at connect (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/mongo_client.js:125:16)
    ERR!     at Function.MongoClient.connect (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/mongo_client.js:109:3)
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46426851
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,63 @@
    +import fs from 'fs';
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo [clustername] [database] [MongoDB-url] [collection]',
    +      'nmo import-mongo [url] [database] [MongoDB-url] [collection]'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (cluster, database, mongourl, collection) {
    +  return new Promise((resolve, reject) => {
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching - ' + err.message;
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error converting - ' + err.message;
    +          reject(err);
    +        })
    +        .pipe(new CouchBulkImporter({
    +          url: clusterUrl + '/' + database
    +        }))
    +        .on('error', function (err) {
    +          err.message = 'Error uploading - ' + err.message;
    --- End diff --
    
    maybe add something like:
    
    ```
     - migration is incomplete 
    ```
    
    to the messages?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-170622409
  
    if the database does not exist, a migration just works on the second call:
    
    ```
    (18:15:18) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo anemone foo mongodb://127.0.0.1:27017/test restaurants
    Migration started!
    ERR! Error migration incomplete - CouchDB server answered:
     Status: 500
     Body: {"error":"error","reason":"internal_server_error"}
    ERR! Error: Error migration incomplete - CouchDB server answered:
    ERR!  Status: 500
    ERR!  Body: {"error":"error","reason":"internal_server_error"}
    ERR!     at CouchBulkImporter.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/index.js:47:21)
    ERR!     at Request.self.callback (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:368:22)
    ERR!     at emitTwo (events.js:87:13)
    ERR!     at Request.emit (events.js:172:7)
    ERR!     at Request.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:1219:14)
    ERR!     at emitOne (events.js:82:20)
    ERR!     at Request.emit (events.js:169:7)
    ERR!     at IncomingMessage.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:1167:12)
    ERR!     at emitNone (events.js:72:20)
    ERR!     at IncomingMessage.emit (events.js:166:7)
    ERR!     at endReadableNT (_stream_readable.js:903:12)
    ERR!     at doNTCallback2 (node.js:439:9)
    ERR!     at process._tickCallback (node.js:353:17)
    ERR!
    ERR!
    ERR! nmo: 1.1.0 node: v4.2.1
    ERR! please open an issue including this log on https://github.com/robertkowalski/nmo/issues
    (18:15:28) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo anemone foo mongodb://127.0.0.1:27017/test restaurants
    Migration started!
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46426463
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,63 @@
    +import fs from 'fs';
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo [clustername] [database] [MongoDB-url] [collection]',
    +      'nmo import-mongo [url] [database] [MongoDB-url] [collection]'
    --- End diff --
    
    same here, https://github.com/apache/couchdb-nmo/pull/16/files#r46426220


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46933121
  
    --- Diff: doc/api/nmo-import-mongo.md ---
    @@ -0,0 +1,11 @@
    +nmo-import-mongo(3) -- import-mongo
    +==============================
    +
    +## SYNOPSIS
    +
    +    nmo.commands.import-mongo([<url> || <cluster>], [database], [mongourl], [collection])
    --- End diff --
    
    still needs to get fixed `<` instead of `[` for database, mongourl and collection


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-161332077
  
    :heart_eyes: :heart_eyes: :heart_eyes: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46949991
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,79 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      err.type = 'EUSAGE';
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        err.type = 'EUSAGE';
    +        reject(err);
    +        return;
    +      }
    +
    +      const clusterUrl = getUrlFromCluster(cluster);
    +      const col = db.collection(collection);
    +      col.find({}, {})
    +        .on('error', function (err) {
    +          err.message = 'Error fetching collection - ' + err.message;
    +          db.close();
    +          reject(err);
    +        })
    +        .pipe(new BulkBadger())
    +        .on('error', function (err) {
    +          err.message = 'Error - ' + err.message;
    +          if (/CouchDB server answered/.test(err.message)) {
    +            err.type = 'EUSAGE';
    +          }
    --- End diff --
    
    with a permission error on couch i get this now:
    
    ```
    ERR! Error fetching collection - server localhost:27017 sockets closed
    ERR! MongoError: Error fetching collection - server localhost:27017 sockets closed
    ERR!     at Server.destroy (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:676:47)
    ERR!     at Server.close (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/server.js:371:17)
    ERR!     at Db.close (/Users/robert/apache/couchdb-nmo/node_modules/mongodb/lib/db.js:335:19)
    ERR!     at CouchBulkImporter.<anonymous> (/Users/robert/apache/couchdb-nmo/lib/import-mongo.js:81:12)
    ERR!     at emitOne (events.js:82:20)
    ERR!     at CouchBulkImporter.emit (events.js:169:7)
    ERR!     at onwriteError (_stream_writable.js:304:10)
    ERR!     at onwrite (_stream_writable.js:322:5)
    ERR!     at WritableState.onwrite (_stream_writable.js:89:5)
    ERR!     at CouchBulkImporter.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/index.js:47:16)
    ERR!     at Request.self.callback (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:368:22)
    ERR!     at emitTwo (events.js:87:13)
    ERR!     at Request.emit (events.js:172:7)
    ERR!     at Request.<anonymous> (/Users/robert/apache/couchdb-nmo/node_modules/couchbulkimporter/node_modules/request/request.js:1219:14)
    ERR!     at emitOne (events.js:82:20)
    ERR!     at Request.emit (events.js:169:7)
    ERR!
    ERR!
    ERR! nmo: 1.1.0 node: v4.2.1
    ERR! please open an issue including this log on https://github.com/robertkowalski/nmo/issues
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46949866
  
    --- Diff: src/import-mongo.js ---
    @@ -0,0 +1,79 @@
    +import Promise from 'bluebird';
    +import CouchBulkImporter from 'couchbulkimporter';
    +import mongo from 'mongodb';
    +import BulkBadger from 'bulkbadger';
    +import { getUrlFromCluster } from './utils';
    +
    +export function cli (cluster, database,  mongourl, collection) {
    +  if (!cluster || !database || !mongourl || !collection) {
    +    const msg = [
    +      'Usage:',
    +      '',
    +      'nmo import-mongo <MongoDB-url> <collection> <clustername> <database>',
    +      'nmo import-mongo <MongoDB-url> <collection> <url> <database>'
    +    ].join('\n');
    +    const err = new Error(msg);
    +    err.type = 'EUSAGE';
    +
    +    throw err;
    +  }
    +
    +  return importmongo(cluster, database, mongourl, collection);
    +}
    +
    +export function validateMongoUrl (url) {
    +  return /mongodb:\/\//.test(url);
    +}
    +
    +
    +export default importmongo;
    +function importmongo (mongourl, collection, cluster, database) {
    +  return new Promise((resolve, reject) => {
    +    if (!validateMongoUrl(mongourl)) {
    +      const err = new Error('Invalid MongoDB url');
    +      err.type = 'EUSAGE';
    +      reject(err);
    +      return;
    +    }
    +
    +    mongo.connect(mongourl, function (err, db) {
    +      if (err) {
    +        err.type = 'EUSAGE';
    --- End diff --
    
    example: mongo db server not running:
    
    ```
    (14:03:21) [robert@tequila-work] ~/apache/couchdb-nmo (pr/16) $ ./bin/nmo-cli.js import-mongo mongodb://localhost:27017/test restaurants anemone restaurants
    ERR! connect ECONNREFUSED 127.0.0.1:27017
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#issuecomment-170887515
  
    Merged


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-nmo/pull/16#discussion_r46426308
  
    --- Diff: doc/api/nmo-import-mongo.md ---
    @@ -0,0 +1,11 @@
    +nmo-import-mongo(3) -- import-mongo
    +==============================
    +
    +## SYNOPSIS
    +
    +    nmo.commands.import-mongo([<url> || <cluster>], [database], [mongourl], [collection])
    --- End diff --
    
    most of them the args are required, see https://github.com/apache/couchdb-nmo/pull/16/files#r46426220


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---