Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query for notes based on a regex match against its backlinks / for loop #135

Closed
timconnorz opened this issue Apr 23, 2021 · 4 comments
Closed
Milestone

Comments

@timconnorz
Copy link

@timconnorz timconnorz commented Apr 23, 2021

It would be incredible to be able to query for all notes with certain backlinks using regex.

I'm aware that there's recently been support for something like:
list where contains(file.inlinks, [[filename]])

But I'd like to generate a list of notes that have backlinks that match a certain regex query. Currently, this doesn't work:
list where regexmatch(file.inlinks, "^Meeting with .+"

This query, if it worked. would give me a list of people who I've had meetings with

Even better would be some way to assess the tags of all the file.inlinks:
list where contains(file.inlinks.tags, "#meeting"

Perhaps this would only be useful if there was a forEach function or an array.map() function of sorts
list where length(file.inlinks.filter(inlink => contains(inlink.tags, "#meeting"))) > 1

@timconnorz timconnorz changed the title Query for notes based on their backlinks Query for notes based on their backlinks / for loop Apr 23, 2021
@timconnorz timconnorz changed the title Query for notes based on their backlinks / for loop Query for notes based on a regex match against its backlinks / for loop Apr 23, 2021
@blacksmithgu
Copy link
Owner

@blacksmithgu blacksmithgu commented Apr 24, 2021

Yeah, the main downside to the declarative nature of dataview is that it's awkward to handle arrays in an intuitive way. Adding lambdas and additional array functions seems like a good idea.

As for the links, I'm looking into making string methods work naturally on links - or at the very least, being able to convert links to strings easily via a string() function.

@raphaelhuleux
Copy link

@raphaelhuleux raphaelhuleux commented Oct 3, 2021

I'm also interested in using regex on the inlinks and outlinks. Namely, I'm trying to get a list of all notes who have an inlink that contains "&" in the title. Any idea how to do this?

@blacksmithgu
Copy link
Owner

@blacksmithgu blacksmithgu commented Oct 3, 2021

If you are just interested in notes which have an inlink that matches something, you can use any and a predicate:

LIST WHERE any(file.inlinks, (l) => contains(string(l), "&"))

@blacksmithgu
Copy link
Owner

@blacksmithgu blacksmithgu commented Oct 3, 2021

Anyway, I haven't looked at this issue in quite some time, but I think almost all of this is achievable in normal dataview. You can use string() to convert a link into it's textual representation, and there are now any, map, filter, all, and join operators for doing some array operations.

Going to close this as "fixed" since this is achievable (and is also doable in DataviewJS).

@blacksmithgu blacksmithgu added this to the 0.4.13 milestone Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants