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
Implement nav/datafy for pull #325
Conversation
They work as pull/pull-many but return maps that impement the datafy/nav dance.
Shouldn’t it be on entity instead? I can see how to make entity navigable, but pull results are often messy, can have multiple entites and arbitrary attrbutes mixed? |
Yeah that sounds more reasonable. I will have a look. |
I updated the PR to extend the Entity type. When datafying an entity it still uses the pull api under the hood to pull all attributes (including reverse attributes). The implementation could be included into impl.entity, but this would introduce a dependency for entity to pull-api. Btw. I also tried to have a look how datomic does implement nav/datafy (regarding what to pull etc.) on their entities, but this is not included in datomic-free. |
Thanks! I’ll take a look later |
Hey @IamDrowsy, I wanted to create a quick WIP for the same issue, your entity datafying is way better than mine, but maybe you could borrow the DB/Datom datafy code from mine: Thanks for the awesome work on this! |
Merge ready? |
@tonsky if you have got the time to review & merge this, it would be greatly appreciated! |
I’ll take a look this week, sorry it was lost for so long :) |
Sorry it took so long. The PR is fantastic, merged fully, deployed as 1.0.4. Thank you @IamDrowsy! |
The PR contains a version of pull/pull-many that decorates the returning maps with implementations of datafy/nav protocol.
When navigating along ref or _ref fields, it pulls the referenced entities from the db.
Currently, when navigating, it always pulls all fields (including the reverse refs) to ensure you can navigate back and forth.
I'm not an expert in implementing datafy/nav so feedback is very welcome.
They could replace pull/pull-many of the core. As there should be no difference if you don't call datafy on the result.
For now I have not looked into ways to make the result of queries navigatable.
This touches #313 .