Insert records with links #3619
-
I have two types, type Person extending Entity {
required property first_name -> str;
required property last_name -> str;
multi link email_addresses -> EmailAddress {
constraint exclusive;
}
}
type EmailAddress {
required property email -> str {
constraint exclusive;
}
required link person -> Person {
constraint exclusive;
}
} I'm trying to work out how to do two things. First, how do I insert a Person with embedded email addresses and reference the Person for the required link on INSERT Person {
first_name := "Alice",
last_name := "Example",
email_addresses := {
(INSERT EmailAddress { email := "alice@example.com", person := ??? }),
}
}; Secondly, suppose I have the UUID for a WITH P := (SELECT Person FILTER .id = <uuid>"2e0d4d70-a52d-11ec-93f8-dffcfe8cf185")
INSERT EmailAddress {
email := "bob@example.com",
person := P,
}; I tried variations of these queries but they don't seem to work INSERT EmailAddress {
email := "bob@example.com",
person := <uuid>"2e0d4d70-a52d-11ec-93f8-dffcfe8cf185",
};
INSERT EmailAddress {
email := "bob@example.com",
person := <Person>"2e0d4d70-a52d-11ec-93f8-dffcfe8cf185",
}; Thank you 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You don't need both a link from
Then, to insert email addresses:
However, in your case you probably just want a multi-property on
|
Beta Was this translation helpful? Give feedback.
You don't need both a link from
EmailAddress
toPerson
and fromPerson
toEmailAddress
, because you can traverse links in backward direction. Here's one way how your schema could look:Then, to insert email addresses:
However, in your case you probably just …