Skip to content

Commit

Permalink
extend API by Sqlg specifics
Browse files Browse the repository at this point in the history
  • Loading branch information
source-c committed Jun 20, 2022
1 parent e7b310f commit 59bedb1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[com.google.guava/guava "31.1-jre"]
[ai.z7/java-properties "1.0.1"]


[org.umlg/sqlg-postgres-dialect "2.1.6"
:exclusions [com.google.guava/guava]]
[org.umlg/sqlg-hsqldb-dialect "2.1.6"
Expand Down
21 changes: 19 additions & 2 deletions src-clj/sqlg_clj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(clojure.lang IFn)
(java.util.function BinaryOperator UnaryOperator)
(java.util Comparator)
(org.umlg.sqlg.structure SqlgGraph)))
(org.umlg.sqlg.structure SqlgGraph SqlgVertex)))

(po/import-macro anon/__)

Expand Down Expand Up @@ -54,10 +54,17 @@
(.addV g ^GraphTraversal label-or-traversal)
(.addV g ^String (util/cast-param label-or-traversal)))))

(defmethod add-V SqlgGraph
([^SqlgGraph g label] (.addVertex g ^String (util/cast-param label))))

(def addV
"Adds a vertex to the traversal. `addV` is equivalent to `add-V`."
add-V)

(defn addV* [^SqlgGraph g label & [m]]
(.addVertex g ^String (util/cast-param label)
(into {} (for [[k v] m] [(util/cast-param k) v]))))

(defmulti add-E
"Adds an edge to the traversal"
(fn [g _] (class g)))
Expand Down Expand Up @@ -581,10 +588,20 @@
[^GraphTraversal t k & ks]
(.project t (util/cast-param k) (util/keywords-to-str-array ks)))

(defn properties
(defmulti properties
"Adds an object to the vertex or traversal."
(fn
([g _] (class g))
([g] (class g))))

(defmethod properties GraphTraversal
[^GraphTraversal t & ks]
(.properties t (util/keywords-to-str-array ks)))

(defmethod properties SqlgVertex
[^SqlgVertex v & ks]
(.properties v (util/keywords-to-str-array ks)))

(defn property
[^GraphTraversal t & args]
(if (instance? VertexProperty$Cardinality (first args))
Expand Down

0 comments on commit 59bedb1

Please sign in to comment.