datascript-dom | uses datascript to query HTML
kandi X-RAY | datascript-dom Summary
kandi X-RAY | datascript-dom Summary
Experiment that uses datascript to query HTML/XML in a DOM-like way
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of datascript-dom
datascript-dom Key Features
datascript-dom Examples and Code Snippets
Community Discussions
Trending Discussions on datascript-dom
QUESTION
There is no out-of-the-box schema feature in Datomic for sorting child entities in a to-many relationship, yet this is a very common requirement. Googling has uncovered a few solutions so I wanted to inventory the variations of requirements and solutions here and hope for comments from the community.
Possible Requirements
- R1: small numbers (N) of child entities (not sure what the small/large threshold should be)
- R2: large numbers of child entities
- R3: single-parent children
- R4: multi-parent children
- R5: recursive children i.e. trees stored in Datomic
My particular use case is R1 + R3 + R5 which I suspect is pretty common but I wanted to enumerate as many as possible so that this might become a useful reference for others in future.
Solutions
- S1: nested component entities with a "position" attribute e.g. Datofu
- S2: add a custom "position" attribute to every child as described using transactor fns here and in this post
- S3: linked list using a "next" attribute on every child entity as implemented in datomic-linklist
- S4: separate wrapper entities representing edges as described in this post
Problems
Each solution seems to have challenges. The ones I can think of are:
- P1: maintaining constant time operations for insert, delete or move operations. There have been suggestions to use fractional numbers for "position" values to avoid having to update all children when re-ordering
- P2: supporting multiple parent relationships with ordering
- P3: complexity of maintaining the positions or edges that store the order as ordering or membership changes.
- P4: changes to a "position" attribute affect the implied "last changed" date for a child entity when it was not actually changed
- P5: queries/pull (particularly recursive queries) can become difficult when connecting through wrapper entities
For my tree use-case, I don't care about P2 and P1 is not a big problem because N is generally low
All this research hasn't helped me find clarity on which solution is best for my tree use case but I'm leaning towards S2. Naturally the least complexity is my goal but I suspect that all solutions will be complex.
Question : do you have any experience with this problem and what can you share that will help others in deciding? I'll add more R's, S's and P's above as they are pointed out. I (and many others) will really appreciate any feedback.
A similar question was asked a couple of years ago but not much happened there.
...ANSWER
Answered 2017-Jun-20 at 16:03It really depends on your actual use case (and you might have several different ones within single DB simultaneously).
First, choose between one-to-many
and many-to-many
parent-child relationship:
one-to-many
means you can stick extra attribute right onto child entity, avoiding spending precious datoms on extra:db/id
,:my.domain/guid
,:ordinal/ref
attributes, and on history size.many-to-many
means you have to have separate entity to track ordering among the children.
At this point, you still might want to choose separate entity, to avoid messing up some latest change date
stats/subscriptions on child entities, if you have any. Semantically, changed order of children means parent entity has changed, not the children ones.
Next, getting recursive pull patterns and queries
question out of the way. If you went with an attribute on child
– you are good already.
If you went with separate entity
, keep ordinal entities in a separate attribute on a parent entity:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install datascript-dom
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page