co generator yield not working with mongoclient

226 Views Asked by At
const Db = require('mongodb').Db;
const Server = require('mongodb').Server;
const co = require('co');

const v1Db = new Db('v2-staging', new Server('localhost', 27017));

function* migrateBatch() {
  const collectionV1Uploadfile = yield v1Db.collection('test');

  return {};
}

co(migrateBatch()).then((data) => {
  console.log('end of process');
});

Im using nodejs- v6.9.4 mongo - v3.4.0 version. and gettig the following error. even though mongo documentation says it returns object a collection instance. mongo documentation reference

ERROR (node:96130) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: You may only yi // eld a function, promise, generator, array, or object, but the following object was passed: "[object Object]"

0

There are 0 best solutions below