dynamoid
dynamoid copied to clipboard
How to make foreign key association?
class Workflow
include Dynamoid::Document
include SecureRandom
table name: :workflows, key: :company_id
range :api_name
has_many :workflow_logs
field :company_id, :integer
field :api_name
field :workflow_id, :string, default: SecureRandom.uuid
}
class WorkflowLog
include Dynamoid::Document
table name: :workflow_logs
belongs_to :workflow, foreign_key: :workflow_id
field :company_id, :integer
end
Workflow has primary partition key as company id and sort key api name, i want workflow_id to be foreign key for workflow logs, but its taking company_id value for workflow logs
Could you please provide example of code to reproduce the issue?
The only thing I remember is that associations don't work now when primary key is compound - when there is a range/sort key. So WorkflowLog cannot belong to a model with range/sort key.