Listing using LDFlex


#1

Hi

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


#2

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?


#3

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:

  1. Is there an API reference for query-ldflex? It’s too good a tool to not have that kind of documentation.
  2. 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.

#4

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:

  1. No, unfortunately not yet, but @RubenVerborgh is definitely aware that documentation is needed
  2. I’m not sure exactly what you’re asking for? I’m not familiar with the term predicate-object test.

#5

If using together with globbing, you probably want solid.data.from('/posts/*')[/posts/my-post/].predicate.

Note however that:

  • globbing is at risk of being removed
  • globs that are not ‘all files in folder’ (so not /folder/* but, for instance, /folder/prefix-* work on some versions, but are not universally supported)

For the future, what you probably want is a series of solid.data[/posts/my-post/].predicate; leave it up to the query engine to optimize this into globs or something else.


#6

I’m not sure exactly what you’re asking for? I’m not familiar with the term predicate-object test.

I was conflating two concepts. What I want to know is if it’s possible to run a query like:

SELECT ?v0 WHERE {
  <https://ruben.verborgh.org/profile/#me> <http://xmlns.com/foaf/0.1/knows> ?v0.
  ?v0 <http://xmlns.com/foaf/0.1/givenName> 'James'.
}

#7

@james.martin, @RubenVerborgh
Is is possible to create/delete containers and resources using LDFlex?


#8

These are not pure path queries, and not supported at the moment. (We’re not trying to make LDflex support all of SPARQL, but instead to make some common data accesses simple.)

Not yet; added https://github.com/solid/query-ldflex/issues/27 to track.