Create nested entities for existing parent entity

  class Users < ROM::Relation[:sql]
       schema(:users, infer: true) do
           associations do
               has_many :tasks
           end
       end
end

  class Tasks < ROM::Relation[:sql]
      schema(:users, infer: true) do
         associations do
             belongs_to :user
        end
     end
end


  class UserRepo < ROM::Repository[:users]
    ;# update_data = { user_id: 123, tasks: [{desc: "test"}, {desc: "test1"}]}
     def update_user(update_data)
         users.transaction do
             users
                .tasks
                .by_user_id(update_data[:user_id])
                .changeset(:create, update_data[:tasks])
                .commit
         end
    end
 end

Hi! In the example above, I want to update the user with new tasks (this is how we say in our domain), but the tasks need user_id (i don’t find a good solution making an operation just for merge user_id for each task) for each item and using associate with changeset involves having the user struct. What is the proper way of handling this case with rom?

Did you find a solution?