Listing using LDFlex


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?

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'/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['/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.

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.

If using together with globbing, you probably want'/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[/posts/my-post/].predicate; leave it up to the query engine to optimize this into globs or something else.


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:

  <> <> ?v0.
  ?v0 <> 'James'.

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

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 to track.


Is there a simple way with LDFLEX to get the for example 30 last message of a Long-Chat ?

The chat is here ( I don’t know why there is a alert with “More than one bookmark file…”
I’ve got an instance to the chat in my publicTypeIndex

the messages are stored in subfolder by date like that

Do I have to ldp:contains the folder for all year/month/day ? or is there a way to get just the last 30 messages? thanks