tombstone logic
This commit is contained in:
@@ -45,9 +45,15 @@ module.exports = cds.service.impl(async () => {
|
||||
if (replicas.length === 0) return //> not affected
|
||||
|
||||
// fetch changed data from S/4 -> might be less than local due to deletes
|
||||
const changed = (await SELECT.from(externalAddresses).where({
|
||||
const externals = await SELECT.from(externalAddresses).where({
|
||||
contact
|
||||
})).filter(({ ID }) => replicas.some(rep => ID === rep.ID))
|
||||
})
|
||||
|
||||
const changed = replicas.map(rep => {
|
||||
const ext = externals.find(ext => ext.ID === rep.ID)
|
||||
if (ext) return ext
|
||||
return { ...rep, ...{ tombstone: true } }
|
||||
})
|
||||
|
||||
// update local replicas with changes from S/4
|
||||
const local = db.transaction(msg) //> using that variant to benefit from bulk runs
|
||||
|
||||
Reference in New Issue
Block a user