Enhancement Request: Support for Bi-Directional Relationships #8508
raccoon70
started this conversation in
Feature Requests & Ideas
Replies: 2 comments
-
It sounds like you're looking for the new Join field in V3.0 |
Beta Was this translation helpful? Give feedback.
0 replies
-
However, the Join field doesn't provide a real bi-directional relationship in schema. For use cases like using drizzle directly, without bi-directional relations in the auto-generated schema may have some difficulties for querying(It is likely due to my skill issue anyway). Is there any possible to give relationship field an extra props that adds relations for the relationTo collection as well to make it a real bi-directional relationship? cc @r1tsuu |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
Payload CMS currently supports one-way relationships (e.g., belongsTo, hasMany). However, bi-directional relationships are often needed to ensure that related data stays synchronized in both directions (e.g., a Post with an Author, where changes to either are reflected in both models).
Motivation:
Bi-directional relationships will:
• Ensure data integrity between related models.
• Simplify querying and reduce manual relationship syncing.
• Improve the user experience when managing related data.
Proposed Solution:
• Add a bidirectional flag to relationship fields, or
• Provide built-in relationship types like belongsToMany and manyToMany to handle bi-directional syncing automatically.
Example Use Case:
A Project has multiple Collaborators, and Collaborators belong to multiple Projects. Changes in one model should update the other automatically.
Beta Was this translation helpful? Give feedback.
All reactions