tombstone logic

This commit is contained in:
D065023
2019-12-30 14:06:41 +01:00
parent afc5be2610
commit 7db2c6e781

View File

@@ -45,9 +45,15 @@ module.exports = cds.service.impl(async () => {
if (replicas.length === 0) return //> not affected if (replicas.length === 0) return //> not affected
// fetch changed data from S/4 -> might be less than local due to deletes // 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 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 // update local replicas with changes from S/4
const local = db.transaction(msg) //> using that variant to benefit from bulk runs const local = db.transaction(msg) //> using that variant to benefit from bulk runs