Closed james-martin-jd closed 4 years ago
I think the recently resolved https://github.com/LDflex/LDflex/issues/52 might actually solve this for you :)
I don't think that multiple-update change fully solves the problem, just hides it. As far as I can see we would still need a separate create vs update call and round-trip, which could still create race conditions for liveupdates. Theoretically anyway. I think it is much cleaner if we can pass in an array of triples and create the file all at once.
So https://github.com/LDflex/LDflex/issues/52 would be able to create a file with multiple triples atomically, but only if those triples are attached to the same subject. So 52 is not strictly syntactic sugar, it will actually combine them into one request (if on the same subject).
Now possible with
await solid.data['http://example.org/my/new/document'].put('# Turtle', 'text/turtle');
with text/turtle
being the default that can be omitted.
One thing I would like to do is be able to create a new Solid / RDF file with contents already pre-defined. This comes in handy to prevent race conditions. Currently, we have to create the file and then loop over a list of predicates to create separate expressions for each new property and PATCH each one individually.
This causes some unexpected behavior when dealing with LiveUpdates, in lists such as notifications or the Solid React SDK's Tic Tac Toe game list example. Sometimes the LiveUpdate triggers before all the properties are full saved, and any sort of data validation shows it to be false until it is refetched.
It is also not efficient to create a new file and immediately have to run 12 PATCH requests.
What would be excellent is if we could pass an array of
triple
objects into a create function and have it all created together.