mirror of
https://github.com/strapi/strapi.git
synced 2025-10-27 16:10:08 +00:00
feat: add omitIds
This commit is contained in:
parent
2ac90b8e8e
commit
49f290ff97
@ -2,7 +2,13 @@
|
||||
|
||||
const { cleanInverseOrderColumn } = require('../../regular-relations');
|
||||
|
||||
const replaceRegularRelations = async ({ targetId, sourceId, attribute, transaction: trx }) => {
|
||||
const replaceRegularRelations = async ({
|
||||
targetId,
|
||||
sourceId,
|
||||
attribute,
|
||||
omitIds,
|
||||
transaction: trx,
|
||||
}) => {
|
||||
const { joinTable } = attribute;
|
||||
const { joinColumn, inverseJoinColumn } = joinTable;
|
||||
|
||||
@ -11,8 +17,7 @@ const replaceRegularRelations = async ({ targetId, sourceId, attribute, transact
|
||||
.createQueryBuilder(joinTable.name)
|
||||
.update({ [joinColumn.name]: targetId })
|
||||
.where({ [joinColumn.name]: sourceId })
|
||||
// TODO: Exclude some relations from being replaced
|
||||
// .where({ $not: { [inverseJoinColumn.name]: relationsToDeleteIds } })
|
||||
.where({ $not: { [inverseJoinColumn.name]: omitIds } })
|
||||
.onConflict([joinColumn.name, inverseJoinColumn.name])
|
||||
.ignore()
|
||||
.transacting(trx)
|
||||
@ -39,7 +44,7 @@ const cloneRegularRelations = async ({ targetId, sourceId, attribute, transactio
|
||||
)
|
||||
.where(joinColumn.name, sourceId)
|
||||
// TODO: Exclude some relations from being replaced
|
||||
// .where({ $not: { [inverseJoinColumn.name]: relationsToDeleteIds } })
|
||||
// .where({ $not: { [inverseJoinColumn.name]: omitIds } })
|
||||
.from(joinTable.name)
|
||||
.toSQL();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user