2012-03-04 2 views
4

현재, 내 범위 값은 Time.now.to_f에 의해 달성을 BigDecimal이며, 그래서 같이, 사용자의 모든 문서를 검색 할 :AWS SDK로 DynamoDB에서 주문하는 방법은 무엇입니까?

table = dynamo_db.tables['some_table'] 
table.load_schema 
docs = table.items.where(:user_id => user_id).select.map {|i| i.attributes} 

docs는 내림차순 범위 값 에 정렬됩니다.

답변

3

는 SDK 소스 코드에 파고 후, 나는 방법 AWS :: DynamoDB의 :: ItemCollection 번호 쿼리에 대한이 작은 도움이 덩어리를 발견 할 수 있었다, 나는 해시 값 user_id이었다 내 이후

# @option [Boolean] :scan_index_forward (true) Specifies which 
    # order records will be returned. Defaults to returning them 
    # in ascending range key order. Pass false to reverse this. 

내 검색어를 다음과 같이 수정할 수 있습니다 :

docs = table.items.query(:hash_value => user_id, :scan_index_forward => false).select.map {|i| i.attributes} 
+0

예, 실제 Ruby SDK 설명서에 나타나지 않습니다. –

+0

전혀 아닙니다. 이제부터는 설명서 사이트를 보는 대신 소스를 읽도록하겠습니다. –

관련 문제