Parameterized queries

This post was last updated for 369 days ago, and the information may already be changed

Hello,

I would like to be able to use an attribute of the parent block when writing an SQL query in an embed block. For the sake of example, consider I am in the document Trip to the Moon​ and I want to make a query that collects links to it. I would write

select b.* from blocks as b where b.content like "%trip to the moon%" order by updated desc

But I am already in Trip to the Moon​ (a document or a parent block with that name), so ideally I would like to grab the current document's title/name. I would like to replace the literal string "%trip to the moon%"​ with something like :parent.title​. How can I achieve this?

    Welcome to here!

    Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.

    Signup About
    Please input reply content ...
    • ciwoyipang

      In addition, the embedding blocks of the ontology support JS.You can use plugins to enhance embedded block queries.

      siyuan-plugin-data-query

      image.png

    • MiscReply
    • Knuex
      PRO

      The LianDi site requires you to be registered to view it. And to register, it requires a mobile number.

      Is there any way to view that page without registering? @88250

      2 Reply
    • 88250

      We are very sorry. Due to some security reasons, LianDi cannot be accessed without logging in.

    • alvorithm
      VIP Warrior Author

      Hi again,

      I am wondering if using Javascript in the embed block could help here. Because I only get a partial translation and I don't know JS, I don't follow much of what is discussed in the feature request with issue number 9648, proposed by @frostime

      @frostime -- wout be possible to dynamically acquire metadata from the environment (current notebook/doc, preceding block, enclosing superblock) for use in a query by using the new //!js embed functionality?

    • Visit all replies