You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that ConnectAsync has been depreciated, and I'm unable to run the following example.
var db = mongo.ConnectAsync('mongodb://localhost:27017/testdb');
var collection = db.then(function(db) {
return db.collection('testcollection');
});
etl.file('test.csv')
.pipe(etl.csv())
.pipe(etl.collect(10))
.pipe(etl.mongo.insert(collection));
I have tried using newer newer syntax, but getting TypeError: Cannot read property 'insert' of undefined
const fs = require('fs')
const etl = require('etl');
const MongoClient = require("mongodb").MongoClient;
var collection;
(async() => {
await MongoClient.connect('mongodb://127.0.0.1:3001', function (err, client) {
if (err) throw err;
var db = client.db('meteor');
collection = db.collection("Carrier")
});
})()
fs.createReadStream("ins.csv")
// parse the csv file
.pipe(etl.csv())
// map `date` into a javascript date and set unique _id
.pipe(
etl.map(d => {
return d
)
// collect 1000 records at a time for bulk-insert
.pipe(etl.collect(10))
.pipe(etl.mongo.insert(collection))
.promise()
.then(() => console.log("done"), e => console.log("error", e));
I'm seeing the following error:
node index.js
(node:97320) DeprecationWarning: current URL string parser is deprecated, and will be removed ina future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
error TypeError: Cannot read property 'insert' of undefined
at collection.then.collection (/Users/dck/Projects/csv-load/node_modules/etl/lib/mongo/insert.js:24:35)
at tryCatcher (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/promise.js:606:10)
at _drainQueueStep (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:142:12)
at _drainQueue (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (timers.js:632:19)
Unhandled rejection TypeError: Cannot read property 'insert' of undefined
at collection.then.collection (/Users/dck/Projects/csv-load/node_modules/etl/lib/mongo/insert.js:24:35)
at tryCatcher (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/promise.js:606:10)
at _drainQueueStep (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:142:12)
at _drainQueue (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/dck/Projects/csv-load/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (timers.js:632:19)
Any ideas?
The text was updated successfully, but these errors were encountered:
Hi
It seems that
ConnectAsync
has been depreciated, and I'm unable to run the following example.I have tried using newer newer syntax, but getting
TypeError: Cannot read property 'insert' of undefined
I'm seeing the following error:
Any ideas?
The text was updated successfully, but these errors were encountered: