【发布时间】:2012-02-07 23:59:53
【问题描述】:
如何将 PostgreSQL 查询更改为 mongodb bson 调用?我在http://archives.postgresql.org/pgsql-general/2011-10/msg00157.php 中列出了相同的用例,我想通过使用滞后或领先等方法来计算两个日志条目之间的增量时间。 mongodb 中是否有类似 Postgres 的滞后/领先语法的东西?
select
index,
starttime,
endtime,
starttime - lag(endtime) over(order by starttime asc) as delta
from test
http://www.postgresql.org/docs/8.4/static/functions-window.html
我在看http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/,似乎 map / reduce / finalize 应该这样做。 映射 id、开始和结束时间,reduce 什么都不做,然后在 finalize。我几乎可以,有点,有点,看到它......
【问题讨论】: