Skip to content
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.retractEntity doesnt remove datoms that it points to #289

Closed
carocad opened this issue Jan 25, 2019 · 2 comments
Closed

db.retractEntity doesnt remove datoms that it points to #289

carocad opened this issue Jan 25, 2019 · 2 comments

Comments

@carocad
Copy link
Contributor

@carocad carocad commented Jan 25, 2019

In my Datascript instance I store an entity that can be identified with directions/uuid. It has references to other entities through its values like this:

:directions/steps      {:db.valueType   :db.type/ref
                                       :db.cardinality :db.cardinality/many}

and the database also contains step entities but without any identifiable mechanism, like this:

[11 :step/arrive 1525684530 536870925]
[11 :step/distance 18.37155432893358 536870925]
[11   :step/geometry
                                       {:type "LineString",
                                        :coordinates ([8.6452934 50.0876071] [8.6453277 50.0874434])}
                                       536870925]
[11 :step/maneuver 12 536870925]
[11 :step/mode "walking" 536870925]
[12 :maneuver/bearing_after 172.34318235803818 536870925]
[12 :maneuver/bearing_before 0 536870925]
[12 :maneuver/instruction "depart" 536870925]
[12 :maneuver/type "depart" 536870925]

Whenever I use [:db/retractEntity ref] Datascript would correctly remove the entity and its attributes but not the references that its values point to.

So all the step datoms shown above will remain in the database even after I retracted the root directions object.

Please let me know if you need more input.

Hope it helps

@tonsky

This comment has been minimized.

Copy link
Owner

@tonsky tonsky commented Jan 25, 2019

That’s the expected behaviour. If you want those to be automatically removed, you can mark a relation in schema as :db/component true

@tonsky tonsky closed this Jan 25, 2019
@carocad

This comment has been minimized.

Copy link
Contributor Author

@carocad carocad commented Jan 25, 2019

Thanks for the fast reply, I was not aware of this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.