These are chat archives for LearnBoost/mongoose

8th
Feb 2015
Matt Ma
@mattma
Feb 08 2015 19:21

Hello,
I am using mongoose@4.0.0.rc1 and trying to work with Koa.js. I knew that the latest Mongoose is returning the Promise object. Well, but there is no good documentation on it.

How could I build up the MongoDB connection? does it work like previous v3.8.0?

mongoose.connect('mongodb://.....'); Do I need to yield this? By looking at the source of this function, it does not return an Promise

 var db = mongoose.createConnection(opts.dbURI);
  console.log('typeof db.then: ', typeof db.then);   // undefined
Matt Ma
@mattma
Feb 08 2015 19:58
Never mind about this question, mongodb connection works without yield statement. What I understand is, connect operation does not take long time, does not do async. By accessing Mongoose schema, and model on the destination database is fairly quick operation, ONLY CRUD to the DB would yield an Promise.