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

[Feature] Add schema properties to models #51

Merged
merged 4 commits into from
Aug 15, 2020

Conversation

SferaDev
Copy link
Contributor

@SferaDev SferaDev commented Jul 16, 2020

In metadata-sync we use a lot displayName and sometimes plural or collectionName from the schemas. It's the last usage we rely on d2 right now. As part of one of the latest tasks we are needing displayName again and it didn't feel okay to use d2.

const foo = "dataSets";
const { displayName } = api.models[foo].schema;
console.log(displayName);

@SferaDev SferaDev requested review from tokland and adrianq July 16, 2020 10:30
Comment on lines +31 to +47
const schemaProperties: Array<keyof D2SchemaProperties> = [
"klass",
"shareable",
"metadata",
"relativeApiEndpoint",
"plural",
"displayName",
"collectionName",
"nameableObject",
"translatable",
"identifiableObject",
"dataShareable",
"name",
"persisted",
"embeddedObject",
];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we can do this using only the type, as types are not available on runtime....

Copy link
Contributor

@tokland tokland Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with project-monitoring-app, I can access the models info as expected. And code looks good.

@SferaDev
Copy link
Contributor Author

SferaDev commented Jul 21, 2020

The only thing that bugs me a bit is that the models is not string indexed api.models[string] even though we would require to control the not found scenario.

@adrianq adrianq merged commit f537f75 into development Aug 15, 2020
@SferaDev SferaDev deleted the feature/model-schema-properties branch August 17, 2020 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants