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

How to use useQuery() ? #42

Open
unxok opened this issue Apr 22, 2024 · 3 comments
Open

How to use useQuery() ? #42

unxok opened this issue Apr 22, 2024 · 3 comments

Comments

@unxok
Copy link

unxok commented Apr 22, 2024

I really hate to open an issue on a repo that is very clearly not meant to be usable yet, but I wanted to mess around with the plugin since table functionality is checked off on the roadmap.

Anyway, I can't seem to figure out how dc.useQuery is supposed to work in a tsx block? Looking at the different files, it seems you have a custom expression and query language made with Parsimmon, but I can't seem to get any queries to work and I am not really understanding what it is expecting as an input.

Any pointers would be greatly appreciated! I would love to get more familiar with the repo and eventually be able to make some contributions :)

Note : Something super cool to me about this plugin (as it is now even) is that this serves as a jsx/tsx renderer and that alone has many uses even without using any of the data querying functionality... so thank you for all y'all's hard work so far!

@blacksmithgu
Copy link
Owner

Everything in datacore works around React hooks, including useQuery - essentially, inside of a datacorejs block, you can return a React component where you use useQuery:

return function View() {
   const results = dc.useQuery("#tag");
  return <div>{results}</div>;
}

I haven't documented the useQuery API but it is essentially conjunctive logic over tags, folders, and metadata - you'll find it logically similar to Dataview. You can do things like field = value, !(field = value), path("folder") and #tag, and so on.

@blacksmithgu
Copy link
Owner

It's obviously not great UX but you can infer the semantics of what is searchable by reading the parsimmon definition for QUERY_LANGUAGE directly.

@unxok
Copy link
Author

unxok commented Apr 30, 2024

Huh I swear I tried just that and it didn't work. Are you saying to use datacorejs not datacorejsx or datacoretsx? Maybe I didn't try that particularly lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants