Skip to content
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

Changeset for combined relations #492

Open
drqCode opened this issue Apr 10, 2018 · 0 comments
Open

Changeset for combined relations #492

drqCode opened this issue Apr 10, 2018 · 0 comments

Comments

@drqCode
Copy link

drqCode commented Apr 10, 2018

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]
    # new_user = { name: "Jim", tasks: [{desc: "test"}, {desc: "test1"}]}
     def create(new_user)
        users.transaction do
           users.combine(:tasks).changeset(:create, new_user).commit
       end
     end
  end

It seems that users.combine(:tasks).changeset(:create, new_user).commit just inserts only the aggregate root.

@solnic solnic added this to the 5.0.0 milestone Mar 27, 2019
@solnic solnic modified the milestones: 5.0.0, 6.0.0 Apr 18, 2019
@solnic solnic modified the milestones: 6.0.0, 7.0.0 Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants