查询结果ID是不变的,但其余数据是不同的。每条数据按ID为标识,会有许多条。
但有的情况下,只要提取最新的一条数据,所以会出现很多无用数据。想要能按ID字段,去除重复数据。
查了文档,没发现有对结果去重的参数。不知道是不是看漏了。
除了自己每个都针对性的写,是否有什么其他方便的实现方法?
PHPz2017-04-17 15:51:03
If you understand the requirements correctly, you can refer to the content of the following post, which is probably implemented using aggregate:
https://segmentfault.com/q/10...
In addition, RDBMS's distinct can support multiple Column operations; currently MongoDB's distinct only supports one field operation, but MongoDB's aggregate provides rich functions to meet such needs.
For reference!
Love MongoDB! Have Fun!