rdflib.js icon indicating copy to clipboard operation
rdflib.js copied to clipboard

documentation: how to delete/replace nodes or literals?

Open devkral opened this issue 3 years ago • 4 comments

I have some troubles understanding the documentation: how can I delete a literal or node? How can I replace a literal? Can I use sparql for this?

Can you provide some examples? Much thanks in advance.

devkral avatar Nov 28 '20 21:11 devkral

UpdateManager is what your looking for https://linkeddata.github.io/rdflib.js/Documentation/webapp-intro.html

bourgeoa avatar Nov 28 '20 22:11 bourgeoa

I found a way: removeMany for removing nodes before adding the new ones. But is there a more elegant way?

devkral avatar Nov 28 '20 22:11 devkral

I was seeking something to modify a document in the browser. But as I posted, I found the answer (except it is not very elegant).

devkral avatar Nov 28 '20 22:11 devkral

I guess I don't so much think of adding Nodes to the store, as adding arcs, or triples, or Statements -- or facts in fact. So if you add a Node <#john> or a Literal 30 it is always in the context of some fact like <#John> ex:age 30. . You can change the triple <#John> ex:age 30. by replacing it with <#John> ex:age 31. but you aren't really replacing the node 30 with the node 31 as any other triples in the graph keep 30 as 30. Does that make sense?

To add a triple like that you use

store.add(store.sym('https://.......#John') ns.ex('age'), 31)

Where the number 31 gets converted into the appropriate Literal

timbl avatar Jan 27 '21 13:01 timbl