HananoshikaYomaru / obsidian-run

Generate markdown from dataview query and javascript.
https://yomaru.dev
MIT License
34 stars 2 forks source link

Clarifying Question: Does this support DQL? #21

Closed DandyLyons closed 5 months ago

DandyLyons commented 6 months ago

(This is not a Feature Request, so much as just a clarifying question.)

I understand that the plugin supports the dv object from Dataview.

Does obsidian-run support DQL, the Dataview Query Language?

For example does it support inline syntax:

`= this.file.name`

Or query syntax:

LIST 
FROM "My Folder"

If not would it be possible to add support for this to obsidian-run? Do you know if the dv object allows you to run DQL queries?

linear[bot] commented 6 months ago

YOM-695 Clarifying Question: Does this support DQL?

HananoshikaYomaru commented 6 months ago

Yes. dv has an evaluate function. I am sure it works because I am using it.

DandyLyons commented 5 months ago

I see thanks for the quick reply. I'd like to experiment and see if there's a way I might be able to simplify the syntax for obsidian-run

Perhaps this is already possible. (If so, it should be added to the README). I would like to wrap run start around already existing dataview queries rather than being forced to dip into the ts syntax.

For example if I write

```dataview
TABLE
FROM "1. PARA/🏠Areas/✅RESPONSIBILITIES"
    OR [[#]]
WHERE file.name != "✅RESPONSIBILITIES"

I'd like to wrap it in:

%% run start
```dataview
TABLE
FROM "1. PARA/🏠Areas/✅RESPONSIBILITIES"
    OR [[#]]
WHERE file.name != "✅RESPONSIBILITIES"
%%

Btw, thank you for making this really cool plugin. I'm currently working on using Obsidian as a static site generator using Quartz. Unfortunately Quartz is not compatible with Dataview (and they don't have plans to add that compatibility because Dataview isn't currently maintained). So your plugin seems like it could be a really good solution.

HananoshikaYomaru commented 5 months ago

Sorry. I should give you an example. I completely forget that I put it in my obsidian publish.

https://yomaru.dev/700+Knowledge/Run

const query = `
TABLE dateformat(file.mtime, "dd.MM.yyyy - HH:mm") AS "Last modified" 
FROM !"node_modules"  
SORT file.mtime DESC LIMIT 100`

return dv.tryQueryMarkdown(query)
DandyLyons commented 5 months ago

Ok thank you so much. That answers my question. However, perhaps you might consider adding a feature to obsidian-run so that it automatically places the query into tryQueryMarkdown(). That way you could enable a syntax like this:

```dvrun
TABLE dateformat(file.mtime, "dd.MM.yyyy - HH:mm") AS "Last modified" 
FROM !"node_modules"  
SORT file.mtime DESC LIMIT 100
\```

(The slash is just there so that GitHub doesn't hide the syntax, but you get the idea.) Then, users could take a plain dataview query (which they might have many) and they just change it to dvrun. Then it should behave just like before except now it's being run through obsidian-run

HananoshikaYomaru commented 5 months ago

I appreciate the suggestion ❤️ but I don't think I will do it. Although it might sound easy, it is not the intention of obsidian run. Obsidian run is a powerful generic JavaScript evaluator. I think it is a good idea to make a dv helper to favour many obsidian users. But in the end of the day, DQL is not JavaScript and it not is a standard query language and it is going obsolete. I don't want to make obsidian run look any more related to dataview.

In the future, when obsidian support the database feature, most of the obsidian run-dv use case will go obsolete because dataview is going obsolete.

Now the code is clean, the query is clear and I allow all flexibility and compatibility. It is good enough. Less is more.