Search code examples
javascriptnode.jsmongodbmonk

Is there a way to call 'distinct' through monk?


I want to execute the following 'query' on my node.js server:

MongoDB:

db.example.distinct('field')

Expected result: [value1, value2, ..., etc]

I tried this Javascript, but it doesn't work:

db.get('example').distinct('field', function (err, array){...});

But I don't think monk has that method defined. Is there a way to do this?


Solution

  • It's been added to monk. Here's the commit

    Here's the signature

    Collection.prototype.distinct = function (field, query, fn) {}
    

    Are you using the latest version?