Open bourgeoa opened 3 years ago
kb.updater.updateMany is a clone of https://github.com/solid/contacts-pane/blob/1813eac3b885c3d86fa4ed2882fb73d4ec0fabcf/contactLogic.js#L13
export async function updateMany (deletions, insertions) {
const docs = deletions.concat(insertions).map(st => st.why)
const uniqueDocs = Array.from(new Set(docs))
const updates = uniqueDocs.map(doc =>
kb.updater.update(deletions.filter(st => st.why.sameTerm(doc)),
insertions.filter(st => st.why.sameTerm(doc))))
return Promise.all(updates)
}
const uniqueDocs = Array.from(new Set(docs))
is incorrect because all objects are different, we must compare the content.
We can use rdflib.js sameTerm
or equals
that make a node key value comparison in something like :
const uniqueDocs = []
docs.map(doc => {
if (!uniqueDocs.find(item => item.sameTerm(doc))) uniqueDocs.push(doc)
})
Error deleting thing <https://alain.localhost:8443/Contacts/Person/88273c31-f12c-4030-b32c-0bf2b7cbfb0e/index.ttl#this>: TypeError: st is undefined
This is called by https://github.com/solid/contacts-pane/blob/1813eac3b885c3d86fa4ed2882fb73d4ec0fabcf/contactsPane.js#L353
Succeed when replacing :
await kb.updater.updateMany(ds)
by :for (let i in ds) await kb.updater.update(ds[i])