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 functions in codeblocks? #81

Open
uroybd opened this issue Jan 7, 2025 · 4 comments
Open

How to use functions in codeblocks? #81

uroybd opened this issue Jan 7, 2025 · 4 comments

Comments

@uroybd
Copy link

uroybd commented Jan 7, 2025

How to use functions (e.g. link) in codeblocks so that I can transform data from some columns as I wish. For example:

console.log(dc)
// A list of columns to show in the table.
const COLUMNS = [
    { id: "Name", value: page => link(page.$link.value, page.value("title"))},
    {id: "Author", value: page => page.value("authors") },
    { id: "Rating", value: page => page.value("rating") }
];

return function View() {
    // Selecting `#game` pages, for example.
    const books = dc.useQuery('@page and path("Personal/Reading/Books") and exists(rating)');
    

    // Uses the built in 'vanilla table' component for showing objects in a table!
    return <dc.VanillaTable columns={COLUMNS} rows={books} paging={20} />;
}

In this block, the link doesn't work. I tried dc.link too with no success.

@pkb
Copy link

pkb commented Jan 8, 2025

I think the following should work:

{ id: "Name", value: page => page.$link.withDisplay(page.value("title"))}

@uroybd
Copy link
Author

uroybd commented Jan 8, 2025

I think the following should work:

{ id: "Name", value: page => page.$link.withDisplay(page.value("title"))}

It worked. But isn't there any way to use functions listed in the documentation directly?

@pkb
Copy link

pkb commented Jan 9, 2025

There is not, at the moment. To be used from the code block, these functions should be exported from the API, similar to how dv.func works in dataview. However, this is not the case with datacore.

@uroybd
Copy link
Author

uroybd commented Jan 11, 2025

There is not, at the moment. To be used from the code block, these functions should be exported from the API, similar to how dv.func works in dataview. However, this is not the case with datacore.

It will be really nice if these gets exported. It will open up so much possibilities!

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