-
Notifications
You must be signed in to change notification settings - Fork 3
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
How to query models? #40
Comments
Here is the output of iex> Land.land_example
%DgraphEx.Examples.Land{_uid_: nil, address: "123 Maple Rd Phoenix, AZ 88888",
city: "Phoenix", construction_year: "1982", floors: 1, geo_border: nil,
geo_center: nil, land_size: 12, living_space: 8,
owner: %DgraphEx.Examples.Person{_uid_: nil,
address: "456 Maple Rd Phoenix, AZ 55555", name: "Jason Beefcake"},
zipcode: "88888", zoning: "FAKE"} I mutate my schema to ensure iex> {:ok, _} = Repo.request mutation(schema: Land)
{:ok, %{"code" => "Success", "message" => "Done", "uids" => %{}}} Then I do a iex> mutation(set: Land.land_example) |> DgraphEx.Repo.request
{:ok,
%{"code" => "Success", "message" => "Done",
"uids" => %{"land" => "0x12", "owner" => "0x13"}}} Then I query for iex> query(get: :land, func: eq(:zipcode, "88888"))
|> select(%Land{owner: %Person{}})
|> DgraphEx.Repo.request
|> DgraphEx.into(%Land{owner: %Person{}}, :land) Which outputs: %{land: [
%DgraphEx.Examples.Land{_uid_: "0x12",
address: "123 Maple Rd Phoenix, AZ 88888", city: "Phoenix",
construction_year: "1982", floors: 1, geo_border: nil, geo_center: nil,
land_size: 12, living_space: 8,
owner: [%DgraphEx.Examples.Person{_uid_: "0x13",
address: "456 Maple Rd Phoenix, AZ 55555", name: "Jason Beefcake"}],
zipcode: "88888", zoning: "FAKE"}
]} |
@WolfDan I hope this explanation helps. |
The keys to loading nested models are the |
I'm wondering if I should extend |
Totally helps @elbow-jason ! Hum I think there is a problem with Land contains a owner that is a user -> User contains all the lands that owns -> This request other lands and so fort... I think is mostly a user design problem it self but I think cases like those exist, maybe another argument to except always certain fields when request all the vertex? |
For example in the repository example are a vertex called "Land", it contains the model "Person".
How do I query the person data in adition to the Land fields?
The text was updated successfully, but these errors were encountered: