javascript - YUI3 YQL同时使用限制和排序

标签 javascript json yui yql yui3

我有一个 YQL 查询,它组合了一堆 RSS 提要,然后按日期对它们进行排序。它工作得很好,但我希望能够对结果进行分页。

这是我的查询:

select channel.item.title, channel.item.link, channel.item.pubDate, channel.item.description(0) from xml where url in(... urls go here ...) | unique(field='channel.item.link') | sort(field='channel.item.pubDate', descending='true')

问题在于 yql 在排序过滤器之前执行 LIMIT 和 OFFSET。因此,如果我有 LIMIT 5,我最终只会得到列表中第一个 RSS feed 的前 5 项...而不是所有组合 feed 的前 5 项。

有没有办法链接查询,以便我可以获得对所有结果进行排序的所有查询,并调用限制我的结果的查询。

感谢您的帮助。

最佳答案

使用 truncate(count=5) 获取过滤后的 feed 的前 5 项。

select channel.item.title, channel.item.link, channel.item.pubDate, channel.item.description(0) from xml where url in(... urls go here ...) | unique(field='channel.item.link') | sort(field='channel.item.pubDate', descending='true') | truncate(count=5)

或者具有反向排序的 tail() 方法(上面发布的)也可以工作。

参见http://developer.yahoo.com/yql/guide/sorting.html

关于javascript - YUI3 YQL同时使用限制和排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4565680/

相关文章:

javascript - Promise.resolve 没有传入任何参数

javascript - MVC5 : Posting JSON via Ajax not correctly passing data to Controller?

javascript - Y.Lang.isUndefined vs typeof undefined,哪个更好,为什么?

javascript - 使用 YUI 的良好 javascript 事件日历

javascript - 优化 YUI 数据表中多行的删除

javascript - 通过域名访问时页面没有响应

javascript - 使用闭包传递数组值

javascript - 检查本地存储值是否存在

javascript - 在js/angularjs中插入json数组

android - 为 greenDao 和改造创建通用数据模型