mirror of
https://github.com/strapi/strapi.git
synced 2025-11-07 21:58:23 +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;
|
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;
|
const joinTable = attribute.joinTable;
|
||||||
if (!joinTable) {
|
if (!joinTable) {
|
||||||
continue;
|
continue;
|
||||||
@ -151,6 +156,11 @@ const sync = async (
|
|||||||
const targetColumn = joinTable.joinColumn.name;
|
const targetColumn = joinTable.joinColumn.name;
|
||||||
const orderColumn = joinTable.orderColumnName;
|
const orderColumn = joinTable.orderColumnName;
|
||||||
|
|
||||||
|
// Failsafe in case those don't exist
|
||||||
|
if (!sourceColumn || !targetColumn || !orderColumn) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Update order values for each relation
|
// Update order values for each relation
|
||||||
// TODO: Find a way to batch it more efficiently
|
// TODO: Find a way to batch it more efficiently
|
||||||
await async.map(relations, (relation: any) => {
|
await async.map(relations, (relation: any) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user