0

In lithium models, I can use the command() to select distinct of specific field (See distinct selects in lithium):

$blogs = $self->connection->command(array('distinct'=>'blogs', 'key'=>'url'));

which is translated to mongodb command as:

db.blogs.distinct('url');

Now I want to add a condition on type='rumours' in my distinct query:

db.blogs.distinct('url', {type: 'rumours'});

How do I add this {type: 'rumours'} condition in command()?

Community
  • 1
  • 1
anhlc
  • 13,839
  • 4
  • 33
  • 40

1 Answers1

3

The optional argument in the shell method is a "query" document, so if you follow the distinct command documentation:

$blogs = $self->connection->command(
    array('distinct'=>'blogs', 'key'=>'url', 'query' => array( 'type' => 'rumours' ) )
);

So the only thing missing here is the "query" key in the command document you are sending.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317