在Rails中使用Amazon Dynamo DB时如何实现分页 [英] How to implement pagination when using amazon Dynamo DB in rails

查看:72
本文介绍了在Rails中使用Amazon Dynamo DB时如何实现分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Amazon Dynamo DB与rails一起使用。但是我还没有找到实现分页的方法。

I want to use amazon Dynamo DB with rails.But I have not found a way to implement pagination.

我将使用 AWS: :记录:: HashModel 作为ORM。

此ORM支持如下限制:

This ORM supports limits like this:

People.limit(10).each {|person| ... } 

但是我不知道如何在Dynamo DB中实现以下MySql查询。 / p>

But I could not figured out how to implement following MySql query in Dynamo DB.

SELECT * 
  FROM  `People` 
 LIMIT 1 , 30


推荐答案

您使用LIMIT发出查询。如果返回的子集不包含完整表,则返回 LastEvaluatedKey 值。在下一个查询中,将此值用作 ExclusiveStartKey 。依此类推...

You issue queries using LIMIT. If the subset returned does not contain the full table, a LastEvaluatedKey value is returned. You use this value as the ExclusiveStartKey in the next query. And so on...

来自 DynamoDB开发人员指南

这篇关于在Rails中使用Amazon Dynamo DB时如何实现分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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