papacostas
papacostas

Reputation: 858

distinct selects in lithium

Using Lithiums Model, how do you achieve getting a distinct result set of specific fields from a collection in MongoDB?

mongo query:

db.blogs.distinct('url');

Upvotes: 1

Views: 441

Answers (1)

Tyler
Tyler

Reputation: 2126

There currently isn't a way to do this elegantly to my knowledge. You can get results by working with the Pecl MongoDB object directly. The command function allows you to make any call you want.

$db = Connections::get('default');
$blogs = $db->connection->command(array('distinct'=>'blogs', 'key'=>'url'));

Upvotes: 3

Related Questions