solid-client-js icon indicating copy to clipboard operation
solid-client-js copied to clipboard

get thing of type

Open michaud opened this issue 3 years ago • 1 comments

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

michaud avatar Feb 23 '22 11:02 michaud

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 :)

NSeydoux avatar Apr 21 '22 20:04 NSeydoux