You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by robertkowalski <gi...@git.apache.org> on 2016/01/11 12:40:19 UTC
[GitHub] couchdb-nmo pull request: Import mongo collections into CouchDB
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.
---