Giter Site home page Giter Site logo

datomic-helpers's People

Contributors

avodonosov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

datomic-helpers's Issues

How would I refer to non-nested (sibling) entities

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.