mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
fix: bidirectional relations sync
This commit is contained in:
parent
b87e54e6fd
commit
ad216ff22f
@ -73,6 +73,11 @@ const load = async (uid: UID.ContentType, { oldVersions }: LoadContext) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's a self referencing relation, there is no need to sync any relation
|
||||
if (model.uid === uid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const joinTable = attribute.joinTable;
|
||||
if (!joinTable) {
|
||||
continue;
|
||||
@ -151,6 +156,11 @@ const sync = async (
|
||||
const targetColumn = joinTable.joinColumn.name;
|
||||
const orderColumn = joinTable.orderColumnName;
|
||||
|
||||
// Failsafe in case those don't exist
|
||||
if (!sourceColumn || !targetColumn || !orderColumn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update order values for each relation
|
||||
// TODO: Find a way to batch it more efficiently
|
||||
await async.map(relations, (relation: any) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user