简体   繁体   English

锂的独特选择

[英]distinct selects in lithium

Using Lithiums Model, how do you achieve getting a distinct result set of specific fields from a collection in MongoDB? 使用Lithiums Model,如何从MongoDB的集合中获得特定字段的不同结果集?

mongo query: mongo查询:

db.blogs.distinct('url');

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. 您可以通过直接使用Pecl MongoDB对象来获得结果。 The command function allows you to make any call you want. command功能使您可以拨打任何电话。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM