-
Notifications
You must be signed in to change notification settings - Fork 2
Relationship CRUD
Michel Perez edited this page Oct 17, 2015
·
5 revisions
A Relationship must inherit from the class Rel[A,B]:
case class MyRel(from: MyUser, to: MyUser, enabled: Boolean) extends Rel[MyUser, MyUser]
For persisting this class we need to create and make implicit a Mapper and a NeoRel for the class:
implicit val myRelMapper = Mapper.build[MyRel]
implicit val userRel = NeoRel[MyRel, MyUser, MyUser]("friendship", true)
Important! for creating the NeoRel the NeoNode for A and B has to be available via implicit.
import com.kreattiewe.neo4s.orm.NeoRelOperations._
val rel = MyRel(node1, node2, true)
rel.save()
By importing the NeoRelOperations we can use the CRUD operations on our relationships. That way we can call the methods save, update, delete, methods on the case class node.