You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.
Is your feature request related to a problem? Please describe.
One of the issues I am currently facing is managing relationships between data. E.g. Suppose I have a many-1 course-teacher mapping. It would be nice to get the teacher information along with a course and vice-versa.
Describe the solution you'd like
Section tags could get a relation key-value pair, such as this:
<!-- One course can have one teacher -->
{{#section courses multiple=true relation=teachers mapping=one key=email}}
<h2>{{name}}</h2><p>{{description}}/p><p>{{price}}</p>
{{/section}}
And the corresponding teacher section will get its mapping such as:
<!-- One teacher can have many courses -->
{{#section teachers multiple=true relation=courses mapping=many key=slug}}
<h2>{{name}}</h2><p>{{description}}</p><p>{{email}}</p>
{{/section}}
The "mapping" key will have one of two values, "one" or "many", with the default value being "one".
The "key" key allows us to define the respective Foreign Keys.
To access relationships in the respective sections, this is what we would have to write:
{{#section teachers multiple=true relation=courses mapping=many key=slug}}
<h2>{{name}}</h2><p>{{description}}</p><p>{{email}}</p><h2>Courses by this teacher</h2>
{{#loop courses}}
<h3>{{name}}</h3>
{{/loop}}
{{/section}}
Notice the new loop tag.
For one-one mappings, we won't need to use the loop tag. We can simply do this:
<!-- One course can have one teacher -->
{{#section courses multiple=true relation=teachers mapping=one key=email}}
<h2>{{name}}</h2><p>{{description}}/p><p>{{price}}</p><!-- The teacher mapped to this course will be available with a dot notation as the "relation" key's value --><p>{{teachers.name}}</p>
{{/section}}
For multiple relations, the relation key could be comma separated. The position of the parameters must be the same.
In the example below we can see the following relations:
x course(s) - 1 teacher (foreign key is email)
x course(s) - many students (foreign key is email)
x course(s) - one moderator (foreign key is username)
On the CMS UI side, the "key" will be injected automatically in the relevant table.
The Section could also have an indicator that shows the relationships this section has with other sections.
i.e. Teachers and Courses will get a "email" key if it isn't supplied in the UI since it is a requirement for the mapping
and both Courses and Teachers will get a "slug" key even if it isn't referred to in the UI since it is a requirement for the mapping
Describe alternatives you've considered
I haven't found any alternatives yet. I shall add them here if I have any other ideas.
Additional context
I know that Vapid is intentionally simple and the idea of adding relationships in can make things a little complicated, but I would love to have a discussion about the idea and see where it can go :)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is your feature request related to a problem? Please describe.
One of the issues I am currently facing is managing relationships between data. E.g. Suppose I have a many-1 course-teacher mapping. It would be nice to get the teacher information along with a course and vice-versa.
Describe the solution you'd like
Section tags could get a relation key-value pair, such as this:
And the corresponding teacher section will get its mapping such as:
The "mapping" key will have one of two values, "one" or "many", with the default value being "one".
The "key" key allows us to define the respective Foreign Keys.
To access relationships in the respective sections, this is what we would have to write:
Notice the new loop tag.
For one-one mappings, we won't need to use the loop tag. We can simply do this:
For multiple relations, the relation key could be comma separated. The position of the parameters must be the same.
In the example below we can see the following relations:
x course(s) - 1 teacher (foreign key is email)
x course(s) - many students (foreign key is email)
x course(s) - one moderator (foreign key is username)
On the CMS UI side, the "key" will be injected automatically in the relevant table.
The Section could also have an indicator that shows the relationships this section has with other sections.
i.e. Teachers and Courses will get a "email" key if it isn't supplied in the UI since it is a requirement for the mapping
and both Courses and Teachers will get a "slug" key even if it isn't referred to in the UI since it is a requirement for the mapping
Describe alternatives you've considered
I haven't found any alternatives yet. I shall add them here if I have any other ideas.
Additional context
I know that Vapid is intentionally simple and the idea of adding relationships in can make things a little complicated, but I would love to have a discussion about the idea and see where it can go :)
The text was updated successfully, but these errors were encountered: