avodonosov / datomic-helpers Goto Github PK
View Code? Open in Web Editor NEWConvenience functions to populate Datomic DB with data, to define DB schema.
License: MIT License
Convenience functions to populate Datomic DB with data, to define DB schema.
License: MIT License
Looking at the code I was first under the impression that perhaps you were relying on datomic's non-duplicate support for forcing entities that might be referenced in siblings (but should be a single entity) from being duplicated; however, it seems this is not the case. When I run your sample from the README and look at the database I see this:
{:community/neighborhood {:db/id 17592186045445}, :community/type #{:community.type/email-list}, :community/orgtype :community.orgtype/community, :community/name "Alki News", :community/category #{"members of the Alki Community Council and residents of the Alki Beach neighborhood"}, :community/url "http://groups.yahoo.com/group/alkibeachcommunity/", :db/id 17592186045444}
{:community/neighborhood {:db/id 17592186045448}, :community/type #{:community.type/blog}, :community/orgtype :community.orgtype/community, :community/name "Alki News/Alki Community Council", :community/category #{"news" "council meetings"}, :community/url "http://alkinews.wordpress.com/", :db/id 17592186045447}
and in these two entities you can see from the source that the neighborhood has the same name (and the implication in the original is that these should be collapsed into the same entity), but these sibling records end up generating two different entities for the same (:community/neighborhood -> Alki
) neighborhood.
It seems that an internal memoization of maps by reference would allow you to do this:
;; pre-define a map (which will have a single reference)
(def common-thing { :neighborhood/name "Alki" })
then you could use the common-thing in multiple places within the data structure in the next to-transaction
:
;; to-transaction remembers references it has generated IDs for, and re-uses the same
;; tempid for repeated references.
(mapcat to-transaction [{:comminuty/neighborhood common-thing ... }
{:community/neighborhood common-thing ...}])
If this seems reasonable, I could look at making a patch and sending a pull request.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.