Skip to content

Commit

Permalink
fixup! Fix many-to-many processing
Browse files Browse the repository at this point in the history
  • Loading branch information
nechaido committed May 17, 2021
1 parent 6c73ba3 commit bba31a6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions metagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ function getPropsAndRelations(model, schema, path = '') {
} else if (model.entities.has(definition.type)) {
props.push({
name,
type: definition.many ? 'Id[]' : 'Id',
type: 'Id',
required: definition.required,
});
/* It's possible that we should check whether target is a detaol*/
/* It's possible that we should check whether target is a detail*/
relations.push({
name,
source: schema.name,
Expand All @@ -85,6 +85,16 @@ function getPropsAndRelations(model, schema, path = '') {
}
}

for (const [name, index] of Object.entries(schema.indexes)) {
if (!index.many) continue;
relations.push({
name,
source: schema.name,
target: index.many,
many: true,
});
}

return { props, relations };
}

Expand Down

0 comments on commit bba31a6

Please sign in to comment.