marcusolsson / obsidian-projects

Plain text project planning in Obsidian
Apache License 2.0
1.5k stars 60 forks source link

DataviewJS - Support #176

Open yurijserrano opened 2 years ago

yurijserrano commented 2 years ago

What would you like to be added?

Good Morning @marcusolsson

Great plugin :)

I saw that your plugin supports returning notes using the Dataview Query Language (DQL), but I was wondering if you could also support DataviewJS in your plugin, which is also part of the Dataview plugin.

REFERENCE - DATAVIEW PLUGIN

Why is this needed?

Practically in all my notes I use DataviewJS, so it would be much easier to build the views I already have by putting the DataviewJS I have already created than to create your version in DQL.

marcusolsson commented 2 years ago

First off, I admit I don't know Dataview well enough right now to tell whether this is a good idea or not. AFAIK Dataview can be use to both query and create views of that data. Right now, this plugin uses Dataview to query data rather than to display it.

My impression of the JS API is that it's mainly used to render data(?), which is not something that I'm planning to support anything soon. Could you maybe provide some examples of queries you'd like to use?

yurijserrano commented 2 years ago

Good Morning @marcusolsson

I hope you are well :)

Regarding this excerpt:

My impression of the JS API is that it's mainly used to render data(?)

DataviewJS provides more flexibility for the user to create the views they want, but it also provides more flexibility for us to get certain notes based on certain criteria.

In this case, since your application provides several views, it would be interesting to include only the DataviewJS functionality to get the notes.

Regarding this excerpt:

Could you maybe provide some examples of queries you'd like to use?

Of course

You can some example right below:

dv.pages() => all pages in your vault
dv.pages("#books") => all pages with tag 'books'
dv.pages('"folder"') => all pages from folder "folder"
dv.pages("#yes or -#no") => all pages with tag #yes, or which DON'T have tag #no
dv.pages('"folder" or #tag') => all pages with tag #tag, or from folder "folder"
dv.pages("#book").where(p => p.rating > 7)
dv.pages("#book")
    .sort(b => b.rating)
    .map(b => [b.file.link, b.genre, b["time-read"], b.rating])

These are the cases that users use the most when it comes to getting the notes they want, in my case I use custom functions as well, for example to return the notes that were created within a specific period of time as you can see below:

image

I hope this help to clarify some points, but if you need anything else, just let me know.

Have wonderful day.

marcusolsson commented 2 years ago

Thanks for the examples! 🙏 I'm happy to add it as long as we can limit it to only return an array of page objects for now. We'd also need to add a drop-down to let the user choose between DQL and DataviewJS.

yurijserrano commented 2 years ago

Thank you so much @marcusolsson

This will help many users as me that end up using the DataviewJS to return specific pages, this way we can reuse this part and let the creation of the views to be handled by your plugin.

Regarding this excerpt:

need to add a drop-down to let the user choose between DQL and DataviewJS

Great idea, this would make the users explicitly choose between DQL or DataviewJS to return the notes.

Once more, thank you so much for providing this plugin.

If you need help with anything else, I am at your disposal.

I wish you a great day.

Acylation commented 1 year ago

Related: https://obsidian.rocks/editing-dataview-tables-with-the-metadata-menu-plugin/