ivaneye / obsidian-files-cooker

An obsidian plugin for moving search files to target folder
Apache License 2.0
45 stars 1 forks source link

Support moving DataviewJS query results to a folder #10

Open wenlzhang opened 1 year ago

wenlzhang commented 1 year ago

Similar to the following issue, it would be great if one can operate on DataviewJS results. https://github.com/ivaneye/obsidian-files-cooker/issues/2

ivaneye commented 1 year ago

I do not find the API for returning query results from a DataviewJS~

wenlzhang commented 1 year ago

Could this be the DataviewJS API you meant? https://blacksmithgu.github.io/obsidian-dataview/api/intro/

ivaneye commented 1 year ago

Could this be the DataviewJS API you meant? https://blacksmithgu.github.io/obsidian-dataview/api/intro/

in this page ~ https://blacksmithgu.github.io/obsidian-dataview/plugin/develop-against-dataview/

wenlzhang commented 1 year ago

Unfortunately, I cannot help coding-wise as I lack the skills.

What about the following? https://github.com/blacksmithgu/obsidian-dataview/issues/42#issuecomment-1317443187

The following plugins also somehow use Dataview's API. Can these provide some help regarding API usage? https://github.com/marcusolsson/obsidian-projects https://github.com/RafaelGB/obsidian-db-folder https://blacksmithgu.github.io/obsidian-dataview/friends/

wenlzhang commented 1 year ago

Version 3.2.4 of the Database Folder plugin supports DataviewJS queries now. Hopefully, this would help implement this feature in some way:

ivaneye commented 1 year ago

Version 3.2.4 of the Database Folder plugin supports DataviewJS queries now. Hopefully, this would help implement this feature in some way:

It only support the pages queries , no the whole DataviewJs code。

For example, if you want to find all pages with tag 'books', you can write DataviewJs below

dv.pages("#books")

but in Database Folder plugin you just need to write #books

If you only need the pages queries , DQL can do the same thing.

wenlzhang commented 1 year ago

If you only need the pages queries , DQL can do the same thing.

Thanks for the clarification!

I understand this. It's just that my usage of Dataview is mostly DataviewJS queries. Therefore, it would be great if Files Cooker can directly operate on DataviewJS queries (for me, page queries are enough), if possible. This way, one does not need to manually re-write all the queries by using DQL. Of course, I am not certain how difficult this would be.

ivaneye commented 1 year ago

I released a new version 1.7.1。 Support DataviewJS like this

let allPages = dv.pages('"Work"');

but code like this will not work

let nofold = '"Work"'
let allPages = dv.pages(nofold);
wenlzhang commented 1 year ago

Support DataviewJS like this

let allPages = dv.pages('"Work"');

Thanks! This already helps a lot.

ivaneye commented 1 year ago

new release v1.7.2 support DataviewJS code like this below:

let nofold = '"Work"'
let allPages = dv.pages(nofold);
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"