I’ve been playing with Query-LDFlex and one of my use cases is the one provided by globbing in the REST API.
Assuming I have a container named /posts in my POD and this container contains resources matching /posts/post-* I need a list of those resources.
So far, I haven’t been able to work this out in LDFlex. This is possible with rdflib.js but I’m using the SDK which uses LDFlex and I’d rather keep the consistency.
Is this possible with LDFlex?
Thanks
Yes, this is possible. I’m working a bit off memory here, but LDFlex has a .from function that you can pass a container, and then fetch things like the ldp:contains predicate. I believe in order to do a conditional you’d have to use a for await loop over the ldp:contains list and then check each item - this sounds heavy but since LDFlex doesn’t actually re-fetch the resource it’s not as bad as it sounds.
Unfortunately I do not believe the .from function is documented anywhere yet. But I think the syntax would be something like solid.data.from('/path/to/container')['predicate'] inside a for await?
Thanks. I played around on the playground (great work on that, btw!), and found that the correct way to list would be solid.data.['/path/to/container']['predicate'] since the container itself is a resource and it’s representation has a ldp:contains predicate. I’m a little confused about what .from does though.
I have two follow up questions:
Is there an API reference for query-ldflex? It’s too good a tool to not have that kind of documentation.
Is it possible to do predicate-object tests using ldflex? I was thinking since it seems to convert the expressions into SPARQL, that might be possible.
Awesome! I’m also a little confused about what .from does, there are some undocumented functions in LDFlex right now, and that’s one of them. I believe .from lets you point LDFlex at a particular document, so you can say “from this document, load this node, then load a property from that node.” I’ve used it in the past to get things like the lastModified date from a container, which I was previously unable to do using the normal way in LDFlex.
To answer your questions:
No, unfortunately not yet, but @RubenVerborgh is definitely aware that documentation is needed
I’m not sure exactly what you’re asking for? I’m not familiar with the term predicate-object test.