Where I can know the detail schema of logseq db

A new to logseq but I did have a programming background.
I check the documentation here to talk about advanced logseq query, https://logseq.github.io/#/page/advanced%20queries

It tells we can find the logseq db schema here:

While also show some example query like this one:

#+BEGIN_QUERY
{:title "All todos with tag project"
 :query [:find (pull ?b [*])
       :where
       [?p :block/name "project"]
       [?b :block/ref-pages ?p]]}
#+END_QUERY

However, I cannot even find the keyword “block/ref-pages” in the db_schema.cljs

I assume the block record in db should has a record with “block/ref-pages” in it, then the schema file should contains something like “block/ref-pages” at least, so did I miss something?

Hey, any comments? I am surprising it seems no one really care about this question, then how people create the magic query without a “schema” to refer?

@winterTTr here it schema logseq/db_schema.cljs at master · logseq/logseq (github.com)

has been replaced with :block/path-refs logseq/db_schema.cljs at master · logseq/logseq (github.com)

1 Like

Thanks very much, @danzu
So, how can I understand about how those schema really implemented internally?

Maybe I can ask a detail example, such as, assume I have a page named “Foo”, so how can I know what exactly “property” from that schema file which related to this “Foo” page.

For example, assume “block/ref-pages” may used as a data binding to this “Foo” block, so how can I know this fact only from that db_schema file except “guess”.

Is there some kind of “magic query” which people can used to understand a full entity + properties. I am trying to build some query, but I have no idea how to get a full property view of internal logseq entity.

Any suggestion would be greatly appreciated.

1 Like

Thx I came here because I have the same question. Maybe, you could update the query examples on your documentation page wherein still says „ref-pages“, see here:

https://logseq.github.io/#/page/advanced%20queries

1 Like

@winterTTr I agree that queries and how they can be used are a really underdocumented feature of Logseq which makes it hard to unlock their power.

Have you tried the developer mode (Settings > Advanced > Developer Mode)? It allows you to view page properties (Three dots in the corner > Show page data) and block properties (right click on bullet > show block data).

2 Likes

I have this question as well. (Links above are dead.)

If there’s no prepared/generated documentation on this, at least some accessible source code file/files that give hints would be great.

1 Like

Here is the current schema file logseq/schema.cljs at master · logseq/logseq · GitHub

2 Likes

You can right click on the block and click on (dev) show block data. It will give the data structure of the block.

In learn datalog today one of the samples you work through is writing a query that returns the identifiers for the database schema. I expect that this is still feasible, but I couldn’t get it to work from copying what worked when I did the tutorial.


below is the answer provided to exercise #2 in Learn Datalog Today: Chapter 4

[:find ?attr ?type ?card
 :where
 [_ :db.install/attribute ?a]
 [?a :db/valueType ?t]
 [?a :db/cardinality ?c]
 [?a :db/ident ?attr]
 [?t :db/ident ?type]
 [?c :db/ident ?card]]

But I get no results returned from it.

Despite not having the context that code comments will have - unless there’s going to be a metadata with text describing the schema element - I still think it provides value and will never cause a version issue for the user.