Nic
Nic

Reputation: 75

Mongodb/Monk 'count' is undefined

Below is a simplified example of what I'm trying to do, just to get .count() working. When I run this I get 'TypeError: undefined is not a function' relating to the count() function.

Looking at docs and other SO questions I really thought this would work, what am I doing wrong

I'm using Mongo ~2.0 and Monk ~1.0.1 inside a small node.js app.

    var db = req.db;
    var col = db.get('misconceptions');

    col.find({questionId: "1", isCorrect: "true"}, {}).count(function (e, count) {
    console.log(count);

});

Upvotes: 1

Views: 480

Answers (1)

Blakes Seven
Blakes Seven

Reputation: 50406

monk does not natively chain operators like this. Instead use this form for .count():

col.count({questionId: "1", isCorrect: "true"},function(e,count) {
    console.log(count);
});

Upvotes: 2

Related Questions