aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

No All / Scan Operation? #130

Closed anizzomc closed 1 year ago

anizzomc commented 1 year ago

Hello!

I'm trying to run the Rails tutorial (https://guides.rubyonrails.org/getting_started.html) but, with a twist... using DDB as database. So instead of creating an active record Article in a SQL DB, I'm trying to do that in a NoSQL.

However, I find myself puzzled as there are no all, find_all operations in the record.

For example, I would like to do Article.all and perform an underlying scan.

Am I missing something?

mullermp commented 1 year ago

There is a find_all for batch reading, but you must know the keys you want to find, or some way to glob all of the keys. I agree about having an all method, it looks like we don't have one.

https://github.com/aws/aws-sdk-ruby-record/blob/445de8e63f218f95afd53f121d84b2ab1a6b1ca9/lib/aws-record/record/item_operations.rb#L502-L536

mullermp commented 1 year ago

You may be able to just use a scan: https://github.com/aws/aws-sdk-ruby-record/blob/445de8e63f218f95afd53f121d84b2ab1a6b1ca9/lib/aws-record/record/query.rb#L88 An all method is maybe syntactic sugar.

mullermp commented 1 year ago

I would recommend adding your own all method that calls scan with no options. Be warned, scan is a very expensive operation (both computationally and financially). I talked this over with others and we do not want to add this method because it is a suitable "foot gun" for your usage bill.