Open tsipa88 opened 4 years ago
Hmm, good question.
But, when I use the secondone (with operator in), i'm getting error Not indexed attributes: :user_id.in
Looks like it's just a warning, not an error.
and the ordering didn't work at all
Yeah. Again, looks like it's completely correct behavior. In DynamoDB sorting works only in Query API call, but Query requires equality condition for partition/hash key, e.g. user_id: 'a'
. Condition 'user_id.in': [1,2,3,4,5]
is only supported by Scan API call which doesn't support sorting.
So you can use sorting only with conditions like Post.where(user_id: 1)
.
Please note - we can use Query with condition like user_id: 'a'
only because there is a global index with user_id
as a hash key.
Hi @andrykonchin. So, no chance for me, am i right? Thanks for reply.
Hi there. I have simple model like
I need to solve two simple problems: 1) Get all posts for one user like:
Post.where(user_id: 1).scan_index_forward(false)
2) Get all posts for multiple users like:Post.where('user_id.in': [1,2,3,4,5]).scan_index_forward(false)
...In the near future I will add pagination and filtering via
post_type
.The firstone works well. But, when I use the secondone (with operator
in
), i'm getting errorNot indexed attributes: :user_id.in
and the ordering didn't work at all. The ordering (scan_index_forward) byposted_at
in both cases is very important. Where did i miss? Thnks. Regards.