1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Rails+dynamodb-local 】配列型でカラムを保存したい

Last updated at Posted at 2023-02-15

はじめに

こちらの記事に続きになります。

dynamodb-localに保存されたレコードを確認すると、配列として保存されてほしいデータが文字列になっていました。
フロントから配列としてデータを受け取れていたので、dynamoidの設定を見直してみることにしました。

backend/app/models/hoge.rb
class Hoge
  include Dynamoid::Document

  table name: :hoges, key: :id, capacity_mode: :on_demand
  field :title, :string
  field :comments, :string ,array: true

end

modelを確認すると、配列型の宣言が間違っていました。
dynamoidの公式ドキュメントを確認すると :array で宣言する必要がありました。

backend/app/models/hoge.rb
class Hoge
  include Dynamoid::Document

  table name: :hoges, key: :id, capacity_mode: :on_demand
  field :title, :string
  field :comments, :array

end

おわりに

はやくdynamodbになれていきたいです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?