Closed unxok closed 2 months ago
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.
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.
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
There are some docs now for the format here - https://github.com/blacksmithgu/datacore/tree/master/docs. datacorejsx
would be the view I recommend by default.
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!