3

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?

GoldfishGrenade
  • 621
  • 1
  • 6
  • 14

1 Answers1

2

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?

Larry Battle
  • 9,008
  • 4
  • 41
  • 55
  • Looks like I am behind on my updates. However... from the package.json on my build and the one I just downloaded from your link, the versions both say 0.7.1... – GoldfishGrenade Jan 28 '15 at 23:54
  • 1
    @GoldfishGrenade Yeah, that's a HUGE problem in the node.js community. I see it all the time were projects add new features without updating their version number. – Larry Battle Jan 29 '15 at 03:32
  • Do they have a provision for sorting distinct? In mongo you can chain a .sort() – mbokil Feb 04 '16 at 16:53