Skip to content

Add support for tempids #9

Description

@OscarMarshall

When inserting data, I would love the ability to give entities a temporary id (could be a string, negative int, keyword, etc.--something that can't be mistaken as a real id) so that multiple instances of that tempid resolve to the same id.

For instance, the example given in the readme which inserts the project

{:name "Learning Clojure"
 :customer {:name "Big Company"}
 :tasks [{:desc "Buy a good book" :effort 1}
         {:desc "Install Java" :effort 2}
         {:desc "Configure Emacs" :effort 4}]
 :members [{:name "Daisy"}
           {:name "Mini"}]
 :manager {:name "Daisy"}}

ends up inserting Daisy twice: once as a member and once as a manager. Two entities with the ids 1 and 2, both with the name "Daisy", are inserted. Adding tempids would allow for the project

{:name "Learning Clojure"
 :customer {:name "Big Company"}
 :tasks [{:desc "Buy a good book" :effort 1}
         {:desc "Install Java" :effort 2}
         {:desc "Configure Emacs" :effort 4}]
 :members [{:id "daisy's tempid", :name "Daisy"} ; notice the id
           {:name "Mini"}]
 :manager {:id "daisy's tempid", :name "Daisy"}} ; notice the id

which would only insert Daisy once.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions