-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I want to update table, how should I do it? #776
Comments
Could you clarify what "update the table" mean? A table schema change or, for instance, changing some item's attribute value?
Right now the "or" operator isn't supported. It's planned to add in some of upcoming releases. Dynamoid https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html |
For example, if I want to add a new field, or add a new global_secondary_index to an existing table, what should I do? :(( |
There are no any means to administer DynamoDB in Dynamoid, mostly because it's ORM and is focused on data manipulation. As far as DynamoDB is a schemaless storage - you don't need to add/delete/change attributes explicitly, like you need to do in a relational database. A schema (a primary key) AFAIK cannot be changed for existing table. You mentioned indices - it's the only schema-related thing that probably makes sense to be supported, like ActiveRecord in Rails supports migrations. TBH it isn't clear to me whether adding migration mechanism to Dynamoid makes sense at all (but I am still considering it) as far as I don't understand clearly the use case. The purpose of the migration mechanism is to be able to create identical table structure in different environments - e.g. test, development, on CI, on staging etc... But the SaaS nature of DynamoDB adds some issues and makes setting up a new environment more difficult so it's probably is being performed manually. |
@andrykonchin Let me ask, I tried the following query but got an error. How should I correct the syntax? Please help me! Thanks Dynamoid::Adapter.new.query("posts", {key_condition_expression: "user_id = :user_id", filter_expression: "id = :id OR category_id = :category_id", expression_attribute_values: {:user_id => "uid1", :id => "postid1", :category_id => "cateid2"}}).to_h
NoMethodError: undefined method `map' for an instance of String |
The adapter's So you can just either materialise Enumerator into Array or iterate it lazily with enum = Dynamoid::Adapter.new.query(...)
# option 1
pages = enum.to_a
# option 2
enum.each do |items, options|
end |
or
condition, how should I write it?it will query like this, example:
Pls help me, thanksss you !
@ckhsponge
The text was updated successfully, but these errors were encountered: