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

Add possibility to include properties from other models #17

Open
sirex opened this issue Aug 30, 2024 · 0 comments
Open

Add possibility to include properties from other models #17

sirex opened this issue Aug 30, 2024 · 0 comments

Comments

@sirex
Copy link
Contributor

sirex commented Aug 30, 2024

There are situations, when same set of properties are used in multiple models. Repeating same properties multiple times, makes it difficult to maintain manifest tables.

To fix that, we could add possibility to include properties from other models:

model property type ref
Place id
id integer
name@lt string
Town id
include Place
City id
include Place

Here, Town and City includes id and name@lt from Place.

All three models have same set of properties. Properties ar defined in a single place and imported into Town and City models.

base models do not include properties, base is used to define model Entity and semantic meaning, base is also used to assigned same identifiers to different models of the same entity.

Models of the same base might have different set of properties, that is why, we need include type, to explicitly specify, properties, to be added to the model.

Includes could be also possible on top of a property, for example:

model property type ref
Country id
id integer
name@lt string
City id
id integer
name@lt string
country ref include Country

Where ref include specifies, that City should incluce all Country properties on top of City/country property.

Also, source values should be joined togeter if including on top of a property, for example:

model property type ref source
Country id /cities/country
id integer @id
name@lt string @name
City id /cities
id integer @id
name@lt string @name
country ref include Country country

Example abbove should be interpreted as follows:

model property type ref source
Country id /cities/country
id integer @id
name@lt string @name
City id /cities
id integer @id
name@lt string @name
country ref Country country
country.id integer country/@id
country.name@lt string country/@name

This would work in a similar way as XSD ref references.

Alternative options, how include syntax could look:

  1. include is provided in a separate row:

    model property type ref
    City id
    country ref Country
    country include Country

    Con of this option is that country property name is dublicated, but on the other hand, include is not a property type. include is a macro used to include properties from other model.

    Pro of this option is that this would better allign with include on the model elvel. In this case, only property name needs to be specified, in order to include on top of a property. This gives more consistency.

  2. Maybe ref is not needed when include macro is used?

    model property type ref
    City id
    country include Country

    Similarly as with the first option, ref could be inferred and there is no need to specify it explicityly. On the other hand, we might want to include on top of a backref property, in this case it is better to specify property type explicitly.

@sirex sirex added the idea label Aug 30, 2024
@sirex sirex mentioned this issue Aug 30, 2024
@sirex sirex added this to Specs Sep 23, 2024
@sirex sirex added ready and removed idea labels Feb 19, 2025
@sirex sirex moved this from Ready to Implementing in Specs Feb 19, 2025
@sirex sirex removed the ready label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Implementing
Development

No branches or pull requests

1 participant