Skip to content

Instantly share code, notes, and snippets.

@devstopfix
Last active July 17, 2016 14:51
Show Gist options
  • Save devstopfix/75772740cfd89d316edec078df5b9ce7 to your computer and use it in GitHub Desktop.
Save devstopfix/75772740cfd89d316edec078df5b9ce7 to your computer and use it in GitHub Desktop.
; Neo4J CREATE
(defn- format-props [props]
"Format a map of {:symbol String} to Cypher format"
(->>
props
seq
(map (fn [[k v]] (format "%s: %s" (name k) (pr-str v))))
(clojure.string/join ", ")))
(defn cypher-create [node props]
"Return a Cypher CREATE statement for given node and map of properties"
(format "CREATE (%s {%s})" node (format-props props)))
;(cypher-create "n:Person" {:name "Andres" :age 25})
;=> "CREATE (n:Person {name: \"Andres\", age: 25})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment