derjust / spring-data-dynamodb

This module deals with enhanced support for a data access layer built on AWS DynamoDB.
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
403 stars 141 forks source link

Investigate support for limits. #44

Open fpoolev opened 8 years ago

fpoolev commented 8 years ago

Perhaps this is already supported, but I am unclear which dynamically generated query features are supported.

Below are examples from: http://docs.spring.io/spring-data/jpa/docs/current/reference/html/

User findFirstByOrderByLastnameAsc();

User findTopByOrderByAgeDesc();

Page queryFirst10ByLastname(String lastname, Pageable pageable);

Slice findTop3ByLastname(String lastname, Pageable pageable);

List findFirst10ByLastname(String lastname, Sort sort);

List findTop10ByLastname(String lastname, Pageable pageable);

mswolfe commented 8 years ago

From what I can tell spring-data-dynamodb supports both findBy and queryBy in a similar fashion. For either case it will attempt to build a dynamo db QueryRequest first and fall back on a Scan if the properties are not a HashKey/RangeKey or listed as the HashKey/RangeKey of a GSI. For scan to work you need to annotate either the class or method with @EnableScan.

I haven't seen anything in the code base that would support things like "Top" or "First", but there is support for Pageable and Sort. With the caveat that Sort will only work if it is performed on a RangeKey and I thought I saw something about Pageable having some limitations as well.

The AND keyword is supported, but OR queries are not.

As for the property comparisons, I have found this method which appears to provide the following support, written as spring-data keyword mapping to dynamodb condition ComparisonOperator keyword:

Lastly, case insensitivity is NOT supported.

Take this with a grain of salt as it just comes from my limited use of the library and poking through the code.

fpoolev commented 8 years ago

Awesome! Thank you for clarifying which comparisons and keywords are supported. We should add this list to the README to clarify the subset of supported features. I'll be looking through this project more in the upcoming days and I hope to use it in a new project. So far I have successfully used the AND keyword and the BETWEEN, AFTER, GREATER_THAN, BEFORE, LESS_THAN, GREATER_THAN_EQUAL, LESS_THAN_EQUAL property comparisons using java.util.Date.

mswolfe commented 8 years ago

I've created the following page in the wiki with the information that I've detailed above: https://github.com/derjust/spring-data-dynamodb/wiki/Supported-Spring-Data-Comparison-Operators

I don't think the page is 100% complete or accurate, but is it enough to close this issue?

@derjust is this a duplicate of issue 5?

fpoolev commented 8 years ago

Yeah, that definitely answered my question however I'd like to keep the issue open a reminder to look into supporting the first and top keywords for limiting queries. I apologize for the combined enhancement request / question post.

derjust commented 8 years ago

It somewhat overlapping with #5 - Following this issue more in what @fpoolev intented

Neuw84 commented 7 years ago

Hi, I am trying to build a query against a table with a timestamp based sorting. The thing is that if I do findByTimestampBetweenAndDevice the query works ok without using @EnableScan.

However if I use findByTimestampBetweenAndDeviceAndRelaysNotNull it throws and Exception saying that I need to use @EnableScan.

I can do a query like the last one using a Query via the Amazon DynamoDB web panel. I am building the query correctly?

Someone has been sucessful with these kind of operators?

Thanks