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
DB properties storage refactoring #11177
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tiensonqin
changed the title
DB properties storage refactor
DB properties storage refactoring
Apr 1, 2024
1. back to use container id + editing block id instead of block dom ref to decide which block is in editing, to simplify edit-block! and reduce browser gc. 2. set next editing block ahead of receiving the data changes from db worker, so the editor feels a bit faster.
they had the same unique db-ident. Ensure a unique db-ident with automatic db-ident suffixes. Also add tests for this and add more sanitization to property db idents
in clobbered db idents. Also rename fn to make its purpose explicit
if they conflict
This allows imported and eventually user classes to have db idents. Updated schema example graph which now imports classes as :schema.class/X. Also fix schema properties which were removed from the debug file and remove unused property uuids
Finally no need to worry about parent-left conflicts and broken chain. With :block/order, we only need to re-compute new orders for siblings with same order (it can happens if there're bugs in our code, or updates from rtc), but it doesn't break UI. Another huge potential benefit after discussing with Zhiyuan is: Ee might be able to simplify both RTC and undo/redo, currently, we need to handle each new op for both of them, with recently refactorings like properties being db attributes, :block/order is a string instead of a ref, we can handle most property value conflicts using last-write-wins, and others (e.g. :block/parent, property with :default type) specifically. I haven't fixed the issues of using :block/left in RTC and undo/redo, because we might change both soon.
Fixes some generation cases like 1 or 2 pages with 1000 blocks. Larger generation with 10k+ blocks still fail b/c of block/order generation. Also remove deleted :block-id-fn
- only use it for user properties - don't use create ident fn to lookup names - fixed get-area-block-asset-url which didn't work for db graphs without the frontend
Any script can pass a :classes config key. schema script no longer needs to manage db ids or db idents
logseq-cldwalker
approved these changes
May 6, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiensonqin Awesome work! ❤️ 🚀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context and Problem Statement
:block/properties
, for example: a book that has authors and a published date will be something like:The above example will be stored as:
:block/properties
, not just the blocks which have the specific propertyProperty keys need to be removed from blocks when deleting a property, for example, the property pair
:authors-uuid #{...}
needs to be removed from the block as below when deleting the property pageauthors
:block/properties
Painful to validate
:block/properties
will overwrite one client's change for that block.Another example is that A adds a person to the "Authors" property, which can have multiple values, while B deletes an existing value. Syncing will lose either A's or B's operation.
Decision
Positive Consequences
Notice
:block/left
has been replaced with:block/order
:block/namespace
has been removed for the db version:block/name
is no longer unique for the db version:block/macros
has been removed, we used it for getting all the dsl queries, which can be addressed by using classes.TODO Address the following issues in other PRs
:block/schema :properties
are stored as refs, I'll handle[:block/schema :classes]
soon. https://linear.app/logseq/issue/LOG-3037/migrate-blockschema-properties-and-classes-to-actual-datascript:block/properties