Skip to content
Snippets Groups Projects
Commit 1e7db076f47c authored by François Ferry's avatar François Ferry
Browse files

feat: allow to have a list of targets as subject or object of relation.

parent cf2cc4c855f9
No related branches found
No related tags found
1 merge request!6Topic/default/msprint3fev
......@@ -29,8 +29,8 @@
},
{
is_in: {
subject: "Museum",
object: "City",
subject: ["Museum"],
object: ["City"],
cardinality: "1*",
},
director: {
......@@ -34,8 +34,8 @@
cardinality: "1*",
},
director: {
subject: "Museum",
object: "Person",
subject: ["Museum"],
object: ["Person"],
cardinality: "**",
},
}
......
......@@ -15,8 +15,8 @@
string,
{
cardinality: CardinalityPair;
subject: keyof E;
object: keyof E;
subject: Array<keyof E>;
object: Array<keyof E>;
}
>;
......
......@@ -91,7 +91,7 @@
const subjectRelations = Object.fromEntries(
Object.entries(schema.relationships).filter(
([_relationName, definition]: [string, S["relationships"][string]]) =>
definition.subject === resource
definition.subject.includes(resource)
)
);
for (const relationName in subjectRelations) {
......@@ -95,7 +95,4 @@
)
);
for (const relationName in subjectRelations) {
const definition: S["relationships"][string] =
subjectRelations[relationName];
const result = await rqlClient.queryRows(
......@@ -101,5 +98,5 @@
const result = await rqlClient.queryRows(
`Any TARGET Where TARGET is ${definition.object},X ${relationName} TARGET, X eid ${params.id}`
`Any TARGET Where X ${relationName} TARGET, X eid ${params.id}`
);
if (result.length !== 0) {
entity[relationName] = result.map((row) => row[0]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment