Listing using LDFlex

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

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:

  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.
2 Likes

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.

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'.
}

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

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

The chat is here https://spoggy.solid.community/public/solidarit/index.ttl#this ( 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 https://spoggy.solid.community/settings/publicTypeIndex.ttl

the messages are stored in subfolder by date like that https://spoggy.solid.community/public/solidarit/2020/01/

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