How to use the couchimport.importFile function in couchimport

To help you get started, we’ve selected a few couchimport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ibm-watson-data-lab / simple-search-service / lib / import.js View on Github external
clear();
   
    var opts = {
      COUCH_URL: cloudant.url, 
      COUCH_DELIMITER: delimiter || ',',
      COUCH_DATABASE: dbname,
      COUCH_TRANSFORM: require(__dirname+ "/transform.js"),
      COUCH_META: theschema,
      COUCH_PARALLELISM: 1
    };
    console.log(filename, opts);
    var doimport = null;
    
    if (filename.indexOf("://") === -1) { //uploaded file
    	doimport = couchimport.importFile(filename, opts , function(err, data) {
    	  callback(err, data);
        });
    }
    else { //file url
    	doimport = couchimport.importStream(request.get(filename), opts, function(err, data) {
    	  callback(err, data);
        });
    }
    
    doimport.on("writecomplete", function( d) {
      console.log("writecomplete", d);
      latestStatus = d;
      d.complete = true;
    }).on("written", function(d) {
      latestStatus = d;
      console.log("written", d);

couchimport

CouchDB import scripts

Apache-2.0
Latest version published 4 months ago

Package Health Score

65 / 100
Full package analysis