Skip to content

Commit

Permalink
docs for property default values, query filters, importing updates
Browse files Browse the repository at this point in the history
and new Scripting section
  • Loading branch information
logseq-cldwalker committed Nov 27, 2024
1 parent 5fe6218 commit f60647e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
15 changes: 10 additions & 5 deletions db-version-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ High level changes:
* Pdf annotations [have a tag](./db-version.md#more-new-tags). This allows annotations to be viewed across pdfs and to have custom views of annotations while using the pdf viewer.

WIP changes:
* Query filters are likely to be changed.
* Whiteboards are disabled for now and will be enabled later.
* Exports to more formats including markdown.
* Sync and RTC will be enabled later.

Miscelleanous changes:
* Scripts using [nbb-logseq](https://github.com/logseq/nbb-logseq) can read and write graphs. Previously with file graphs, scripts could only read graphs.
* Embedded pages and blocks look almost the same as other nodes. The main indicator of an embed will be an icon to the left of the block.
* Default date picker now has an input for typing a date in natural language.
* There is no re-index like in file graphs.
Expand Down Expand Up @@ -77,11 +77,16 @@ Miscelleanous changes:

* Read more about the [new queries](./db-version.md#queries).
* [Simple queries](https://docs.logseq.com/#/page/queries)
* Simple queries are created via the `/Query` command and not the `{{query}}` macro This means that user macros cannot be used to create specialized queries.
* Simple queries can now have titles.
* Some old simple queries for tasks will no longer work and must be manually converted e.g. `(priority A)` -> `(priority high)`.
* The `sort-by` query filter no longer exists. Sorting is done via the table component.
* Simple queries are created via the `/Query` command and not the `{{query}}` macro. This means that user macros cannot be used to create specialized queries.
* Simple queries can have titles.
* When using the query builder, the resulting query's text is not meant to be easily read as internal ids are used for some concepts e.g. properties.
* The query builder's queries run against all [nodes](./db-version.md#nodes) instead of forcing the user to choose between blocks or pages.
* Query filter changes:
* These previous query filters will no longer work and should be manually converted:
* `(page-tags)` -> `(tags)`
* `(page-property)` -> `(property)`
* `(priority A)` -> `(priority high)`
* The `all-page-tags` and `sort-by` query filters no longer exists. Sorting is done via the table component.
* [Advanced queries](https://docs.logseq.com/#/page/advanced%20queries)
* Advanced queries are now edited in a code block which means queries are syntax highlighted.
* Some old advanced queries will no longer work and need to be rewritten. For engineers, see [this file](https://github.com/logseq/logseq/blob/feat/db/deps/db/src/logseq/db/frontend/schema.cljs) and compare `schema` with `schema-for-db-based-graph` to see what has changed.
Expand Down
32 changes: 27 additions & 5 deletions db-version.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Description

This page describes DB (database) graph functionality as of Nov 6th. See [here](https://test.logseq.com/#/) to try the latest stable version. If you're an existing user of Logseq, you'll be interested in [changes with the db version](./db-version-changes.md).
This page describes DB (database) graph functionality as of Nov 27th. See [here](https://test.logseq.com/#/) to try the latest stable version. If you're an existing user of Logseq, you'll be interested in [changes with the db version](./db-version-changes.md).

NOTE: While there is an [automated backup](#automated-backup) for DB graphs, we recommend only using DB graphs for testing purposes.

Expand All @@ -20,6 +20,7 @@ NOTE: While there is an [automated backup](#automated-backup) for DB graphs, we
* [DB Graph Importer](#db-graph-importer)
* [Automated Backup](#automated-backup)
* [Export and Import](#export-and-import)
* [Scripting](#scripting)

## Nodes

Expand Down Expand Up @@ -88,6 +89,7 @@ Property fields in the dropdown menu:

* `Name`: Name to visually identify the property
* `Property type`: This determines what type a property's property values will have. Once a property is used this field cannot change. If you're unsure of what type to choose, use `Text`. See [property-types](#property-types) for more.
* `Default value`: This sets the default value for a property. See [property-default-values](#property-default-values) for more.
* `Available choices`: This limits a property to only have one of the defined choices. See [property choices](#property-choices) for more.
* `Multiple values`: When selected, a property can have multiple values associated with it. All property types can have multiple values except for checkbox and datetime.
* `UI position`: This determines where the property values are displayed. By default the values are displayed as a row-like block under a block (`Block properties`). You can also choose to display property values at the beginning like task status, under a block like deadline date, or at the end of a block.
Expand Down Expand Up @@ -116,6 +118,14 @@ Property choices allow a property to only have one of the defined choices. Only

If a property has already been used, it is possible to convert it to use choices. After clicking `Add choice`, a panel displays to convert all existing property values to choices. If a property is using choices, it is possible to stop using choices by deleting them from the property. Caution: deleting a choice from a property also currently deletes the choice from all blocks it is used.

### Property Default Values

Properties can have default values, currently just for the types Text, Number and Checkbox. A property's default value takes effect for these two use cases:
* When a property is added to a node, it defaults to the default value.
* When a property is a tag property for a tag and that tag is added to a node, the node defaults to having the default value for that property.

When using simple queries, properties for the above two use cases will have that default value. When using property choices, one of them can be set as a default value by checking the default choice box in the list of property choices.

## New Tags

NOTE: New tags are currently labeled as tags in the app and should be backwards compatible with the previous tags. These `new tags` are also known as classes, types or supertags. Feedback is welcome on names for `new tags`.
Expand Down Expand Up @@ -223,7 +233,7 @@ Journals are automatically created for the current day in the Journals view. The

### Queries

A [query](https://docs.logseq.com/#/page/queries) and [advanced query](https://docs.logseq.com/#/page/advanced%20queries) have the [new tag](#new-tags) `#Query`. Queries are created in one of the following ways:
A [(simple) query](https://docs.logseq.com/#/page/queries) and [advanced query](https://docs.logseq.com/#/page/advanced%20queries) have the [new tag](#new-tags) `#Query`. Queries are created in one of the following ways:
* Type the `/Query` command to create a query through the [query builder](https://docs.logseq.com/#/page/query%20builder).
* Type a simple query in a block and then type the `/Query` command to run the query.
* Type the `/Advanced Query` command to create an advanced query.
Expand Down Expand Up @@ -284,9 +294,13 @@ The DB Graph Importer converts a file graph to a DB graph. Some of the main thin
* `LATER` -> `Todo`
* `IN-PROGRESS` and `NOW` -> `Doing`
* `WAIT` and `WAITING` -> `Backlog`
* Tags are handled as follows:
* For blocks the importer converts all uses of [new tags](#new-tags) to [page references](https://docs.logseq.com/#/page/term%2Fpage%20reference) because ~~tags are now used for new tag features while page references handle inline referencing functionality~~ this behavior is still WIP.
* For pages the importer imports the previous tags to a `Page Tags` property. If you'd like some previous tags to behave like new tags, you can specify them in the first optional input. Using this option also results in those converted tags not being imported as `Page Tags`. The importer also provides two options to convert property related pages to new tags.
* Tags are imported as follows:
* By default, all tags are imported as [new tags](#new-tags) using the `Import all tags` input. This allows you to use all your tags as you have previously, along with the new capabilities they have.
* Alternatively you can import only specific tags to [new tags](#new-tags) using the `Import specific tags` input. Tags that aren't specified in this input are then imported as follows:
* All such tags become pages.
* Tags in a block are converted to [page references](https://docs.logseq.com/#/page/term%2Fpage%20reference).
* Tags associated with a page are associated to that page with a `Page Tags` property.
* Tags are removed from their blocks when the `Remove inline tags` checkbox is checked. This matches the behavior of the DB version.
* Property types are automatically detected for Number, Date, Checkbox, Url, Node and Text. If a property value has two conflicting but compatible types like Number and Text, it will choose the more lenient Text type.


Expand All @@ -312,3 +326,11 @@ An automated backup of graphs is available by clicking on the upper right three
Currently the graph can only be exported as a [SQLite](https://sqlite.org/) DB file. To do so, click on the three dots menu in the upper right corner, select `Export Graph` and click the `Export SQLite DB` item. This creates a .sqlite file for use with Logseq. From that same menu, you can also select `Export both SQLite DB and assets` to create a .zip file which contains the .sqlite file and any asset files packaged as a .zip file.

To import the exported .sqlite file, click on the three dots menu in the upper right corner, select `Import` and click the `SQLite` item.

## Scripting

DB graphs are scriptable using https://github.com/logseq/nbb-logseq/tree/feat/db. Scripts can both read and _write any_ data in a DB graph. To write your own script, you'll need a package.json and nbb.edn. Use [this example package.json](https://github.com/logseq/publish-spa/blob/feat/db/package.json) and [this example nbb.edn](https://github.com/logseq/publish-spa/blob/feat/db/nbb.edn). Some example scripts:

* https://github.com/logseq/logseq/tree/feat/db/deps/db/script - Scripts to query, validate and create any graph
* https://github.com/logseq/logseq/blob/feat/db/deps/outliner/script/transact.cljs - Script to transact (modify) nodes queried from the commandline
* https://github.com/logseq/logseq/tree/feat/db/scripts/src/logseq/tasks/db_graph - More complex scripts to generate graphs with all property types or with schema.org's ontology. See [this readme](https://github.com/logseq/logseq/tree/feat/db/scripts#nbb-scripts) for using these.

0 comments on commit f60647e

Please sign in to comment.