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

Request for supporting associations and resolvers #47

Open
goravbhootra opened this issue Nov 9, 2019 · 3 comments
Open

Request for supporting associations and resolvers #47

goravbhootra opened this issue Nov 9, 2019 · 3 comments

Comments

@goravbhootra
Copy link

Hi,

This is a request for supporting associations and resolvers. Something like following:

defmodule Person do
  use Dlex.Node
  @derive {Phoenix.Param, key: :uid}

  import Ecto.Changeset

  schema "persons" do
    field :name,      :string
    field :age,       :integer
    field :works_at,  :uid, model: Company
    field :company_count, :integer, virtual: true, resolve: "count(works_at)"
  end

  ...

Thanks,
Gorav

@liveforeverx
Copy link
Owner

liveforeverx commented Nov 13, 2019

Hi!

Thank you for request! 👍

Are there any analogy functionality to resolve in ecto? I would like to see find something similar in ecto, before continue on this.

@goravbhootra
Copy link
Author

@goravbhootra
Copy link
Author

goravbhootra commented Nov 14, 2019

Also, how do we handle associations? has_many and belongs_to which ecto supports?

Could we have something like:

defmodule App.Person do
  ...
  has_many :lands, [:uid]
  ...
end

defmodule App.Land do
  ...
  belongs_to :person, :uid
  ...
end

AND

defmodule App.Land do
  ...
  belongs_to :owner, :uid, type: App.Person, reverse: true
  ...
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants