These are chat archives for LearnBoost/mongoose

9th
Feb 2015
Valeri Karpov
@vkarpov15
Feb 09 2015 01:38
You're right @mattma. Mongoose does some queueing under the hood when you try to do async operations while it isn't connected
Matt Ma
@mattma
Feb 09 2015 01:44

@vkarpov15 Here is another question. I got it working. So mongoose connects to mongodb. Then, I query the db, it is all good.

function getByUsername () {
  return function *getByUsername (next) {
    var User = this.state.models.User;
    var username = this.params.username;

    this.body = yield User.findOne({username: username}).exec();
  }
}

This is the request path '/users/:username come in. this.params.username would return the username to query the collection name user. If I have an username john, I query /users/john, it is all good and returns the john document.

But If i query /users/doe, query doe, there is no doe document. It will output an error, and kill my process.

/Users/qma17/Desktop/repos/default/ts/node_modules/mongoose/node_modules/mongodb/lib/server.js:226
        process.nextTick(function() { throw err; })
                                            ^
Error
    at Object.<anonymous> (/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:42:24)
    at Module._compile (module.js:446:26)
    at Object.Module._extensions..js (module.js:464:10)
    at Module.load (module.js:341:32)
    at Function.Module._load (module.js:296:12)
    at Module.require (module.js:351:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/index.js:2:17)
    at Module._compile (module.js:446:26)
    at Object.Module._extensions..js (module.js:464:10)
Is that because I do not have an Error handler in this case?
MongoDB 3.0 is going to be released by Feb 19th, Mongoose is going to upgrade/support to 3.0 by any chance?
Valeri Karpov
@vkarpov15
Feb 09 2015 02:49
mongoose 4 will support 3.0, that's correct. As for the error, that's unexpected. Can you open up an issue on github with that?
Ilan Biala
@ilanbiala
Feb 09 2015 02:50
@vkarpov15 MongoDB 3.0 was just released this past week it seems. How much work is required to get that working properly with Mongoose?
Matt Ma
@mattma
Feb 09 2015 05:04
@vkarpov15 Thanks. It may be something that I did wrong. I need more tests.
Valeri Karpov
@vkarpov15
Feb 09 2015 14:55
@ilanbiala nope, 3.0.0-rc8 was released last week. 3.0.0 is still waiting :) but mongoose works fine with mongodb 3.0.0-rc8 as far as I can tell
Valeri Karpov
@vkarpov15
Feb 09 2015 23:51
Heya, anybody know domains really well? I've been bashing my head against LearnBoost/mongoose#2464 for a while and haven't made much progress beyond figuring out that setImmediate isn't firing when mquery uses it to wrap callbacks in a domain and domain.dispose() has been called