solid-client-js
solid-client-js copied to clipboard
get thing of type
Search terms you've used
getThing
Feature suggestion
Get a Thing not by iri but by type.
const bag = getThingOfType(ds, golf.classes.Bag)
const clubs = getThingAllOfType(ds, golf.classes.Club)
Expected functionality/enhancement
getThingOfType returns the first Thing of that type, getThingAllOfType returns all Things of that type
Actual functionality/enhancement
at the moment you have to know the iri of the Thing to be able to get the Thing from the Dataset or you have to use getThingAll and filter the items by checking the type. If you have one Thing of type in the document this seems overly verbose. Also you don't always know the iri of the Thing: "https://test.inrupt.net/public/golf/data/clubs.ttl#164561119414735272867392814433"
Use Cases
load a list of Things, show those things in a UI, manipulate those Things
That's a good idea, and it could be generalized to something like getThingMatching(predicate, object)
. getThingOfType
would then approximately be const getThingOfType = (type) => getThingMatching(RDF.type, type);
I haven't forgotten about this issue, but I don't know when I'll be able to work on it :)