These are chat archives for Automattic/mongoose

3rd
Aug 2017
khelkun
@khelkun
Aug 03 2017 12:38

Hi. About mongoose 4.11 and useMongoClient option: how am I supposed to rewrite the following createConnection please?

mongoose.createConnection('mongodb://localhost:27017/mern-test', err => {
      if (err) t.fail('Unable to connect to test database');
      done();
    });

I was thinking about this:

mongoose.createConnection('mongodb://localhost:27017/mern-test', { useMongoClient: true}, err => {
      if (err) t.fail('Unable to connect to test database');
      done();
    });

But the "err " callback is not passed to openUri in the Mongoose.prototype.createConnection function

should I use promise?
khelkun
@khelkun
Aug 03 2017 12:44
like that:
mongoose.createConnection('mongodb://localhost:27017/mern-test', { useMongoClient: true }).then(
    () => {},
    err => {
      if (err) t.fail('Unable to connect to test database');
      done();
    }
);
Jan Dočekal
@violetzie
Aug 03 2017 14:45
Hello, is there a way of saving/storing a javascript code ("<script>some code</script>") in mongo using mongoose?