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

feat: Add expand-flag to RelationalBone #905

Closed

Conversation

phorward
Copy link
Member

@phorward phorward commented Oct 11, 2023

Allows for specific renders to expand the values of a RelationalBone to its full dest-skeleton, and not only the specified refKeys.

This is useful to directly fetch entire data structures with just one request, and is useful for modern single-page-apps.

Example usage:

class UserPortal(Skeleton):
    portal = RelationalBone(
        descr="Portal",
        kind="portal",
        expand=True,
        readOnly=True,
        format="$(dest.identifier)",
        refKeys=["key", "identifier", "name"],
        consistency=RelationalConsistency.CascadeDeletion,
    )

This expands portal to its full skeleton, including all descriptions, logos, marketing-huiuiui-wheeee-images and texts without spamming the datastore, by extending all bones to refKeys. The userportal entity still only stores the values in refKeys.

Allows for specific renders to expand the values of a RelationalBone to its fulldest-skeleton, and not only the specified refKeys.

This is useful to directly fetch entire data structures with just one request, and is useful for modern single-page-apps.
@phorward phorward added this to the ViUR-core v3.6 milestone Oct 11, 2023
@phorward phorward added feature New feature or request viur-meeting Issues to discuss in the next ViUR meeting labels Oct 11, 2023
if bone.expand:
skel = skeleton.skeletonByKind(bone.kind)()
if not skel.fromDB(dest["key"]):
return None # FIXME: Shall I raise?
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, of course! Otherwise there wouldn't be a difference between no and invalid data!

@sveneberth
Copy link
Member

Do we need to think about recursion in case of nested relBones? I think this correlates in some case with #143. I mean in some cases you want to expand the sub relBone, in others not.
Imagine these relational models: A -> B -> C and D -> B -> C. The cascade of the RelationalBone in A (to B, which as a relation to C) should completely expand B and C. But the RelationalBone in D should only expand B, but not C.

@phorward phorward added the discussion These topics must be discussed before completion label Oct 13, 2023
@phorward phorward removed the viur-meeting Issues to discuss in the next ViUR meeting label Nov 10, 2023
@phorward
Copy link
Member Author

Alternative replacement provided by #1193, issued #1101.

@phorward phorward closed this Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion These topics must be discussed before completion feature New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants