锂的独特选择 [英] distinct selects in lithium

查看:67
本文介绍了锂的独特选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用锂模型,如何实现从MongoDB的集合中获得特定字段的不同结果集?

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

mongo查询:

db.blogs.distinct('url');

推荐答案

据我所知,目前还没有一种优雅的方法.您可以直接使用 Pecl MongoDB 对象来获得结果. command功能允许您拨打所需的任何电话.

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'));

这篇关于锂的独特选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆