I'm using the library gremlin-scala
to interact with Janusgraph.
Using the DSL, a way to insert a new vertex is by doing the following:
val Id = Key[Long]("id")
val Name = Key[String]("name")
graph + ("label", Id -> 42, Name -> "Mike")
I want to make this part into a a function ("label", Id -> 42, Name -> "Mike")
case class VertexModel(id: Long, name: String) {
def toVertex: (Label, KeyValue[Long], KeyValue[String]) = {
val Id = Key[Long]("id")
val Name = Key[String]("name")
("item", Id -> id, Name -> name)
}
}
val model = VertexModel(1, "Bill")
graph + model.toVertex
This fails with the following error:
Error:(26, 11) type mismatch;
found : T1
required: gremlin.scala.Label
(which expands to) String
graph + vertex
Error:(26, 11) type mismatch;
found : T2
required: gremlin.scala.KeyValue[Long]
graph + vertex
Error:(26, 11) type mismatch;
found : T3
required: gremlin.scala.KeyValue[String]
graph + vertex
Not sure how to fix this.
Why do you need extension method
toVertex
?Doesn't this work just like
?
build.sbt