This thread covers my discoverings on the subject: My first app - adding resources?
I’ve managed to use RDFLIB without any low level HTTP work. Add, Query, Update, Delete works like this:
Adding resource at URL X:
- Add statements <X, some-predicate, some-value, X> for each property of the resource. Use store.add(X,p,v,X) to save the statements locally;
- PUT the new statements onto the web: Use fetcher.putBack(X);
Reading list of resources:
- Load all resources into local store using the fetcher to first load the container and then load each item, one by one, in it.
- Extract all the found data from the local store. Use store.match(…)
Remove a single resource at url X:
- Remove the resource from the web. Use fetcher.delete(X).
- Remove local knowledge of the resource: Use store.removeDocument(X).
- Remove all local statements: Use store.removeMatches(X);
Update a single resource at url X:
- Use update-manager.update()
- Or replace it completely with fetcher.putBack(x) … haven’t tried this though.
And beware that the web-oriented operations in the fetcher are all async using promises.
It took me a while to figure out why my “refresh list” operation did not include a newly added resource. That was because the “put” operation executed asynchronously and did not complete before the refresh list called the server for a an update.
Be careful to add await .then() and .catch() to the right places in your code.
See also my experimental “Object to RDF mapper” at https://github.com/JornWildt/SolidRC/blob/master/wwwroot/js/ORDFMapper.js that includes all the CRUD methods.