Page MenuHomeSealhub

DeepReverseSingleReference - shorter notation
Closed, ResolvedPublic2 Points

Description

Currently the DeepReverseSingleReference field in Sealious has a quite bloated definition:

export default class BlogArticles extends Collection {
	fields = {
                // ...
		categories: new FieldTypes.DeepReverseSingleReference({
			intermediary_collection: "article-category",
			intermediary_field_that_points_here: "article",
			intermediary_field_that_points_there: "category",
			target_collection: "article-categories",
		}),

It's... not pretty. And redundant - the three last arguments in this example can be deduced from the first one in most cases. The constructor for DeepSingleReference should have an alternative constructor where we only pass the intermediary collection name:

export default class BlogArticles extends Collection {
	fields = {
                // ...
		categories: new FieldTypes.DeepReverseSingleReference("article-category"),

It should look into the article-category and deduce the other params from the fields in that collection.

Note that the intermediary collection may have not been initialized yet when the BlogArticles collection is being initialized. We need to do this on start of the application, then.

If it's not possible to unambiguosly assign the proper fields and target collections, throw an error explaining that the user must use the original syntax, with an example of that original syntax.

Update the docs to match the new syntax.

Details

Tested by
jenkins-user
Coded by
FilipI
Reviewed by
kuba-orlik
Action required from
FilipI

Revisions and Commits

rS Sealious
Restricted Differential Revision

Event Timeline

jenkins-user updated Coded by, added: FilipI.
jenkins-user updated Action required from, added: FilipI.
FilipI added a revision: Restricted Differential Revision.Aug 29 2024, 23:55
jenkins-user moved this task from Doing to Review on the Kanban board.
jenkins-user added a subscriber: FilipI.
kuba-orlik triaged this task as Above Normal priority.Oct 6 2024, 12:32
jenkins-user moved this task from Review to Doing on the Kanban board.
jenkins-user updated Reviewed by, added: kuba-orlik.
jenkins-user moved this task from Doing to Review on the Kanban board.
jenkins-user updated Action required from, added: kuba-orlik; removed: FilipI.
jenkins-user moved this task from Review to Doing on the Kanban board.
jenkins-user updated Action required from, added: FilipI; removed: kuba-orlik.
jenkins-user moved this task from Doing to Review on the Kanban board.
jenkins-user updated Action required from, added: kuba-orlik; removed: FilipI.
jenkins-user moved this task from Review to Doing on the Kanban board.
jenkins-user updated Action required from, added: FilipI; removed: kuba-orlik.
jenkins-user moved this task from Doing to Review on the Kanban board.
jenkins-user updated Action required from, added: kuba-orlik; removed: FilipI.
jenkins-user moved this task from Review to Ready for testing on the Kanban board.
jenkins-user updated Tested by, added: jenkins-user.
jenkins-user moved this task from Ready for testing to Ready to land on the Kanban board.
jenkins-user updated Action required from, added: FilipI; removed: kuba-orlik.