Eduard Baraniak
Eduard Baraniak

Reputation: 431

Read only attributes in graph database

I want to make property read-only. When I am creating Vertex in DB i want to set property value and do not allow update in future. Is there any possible solutions on DB side? Or I have to do it in my scala Back-end? What is the best practise? Thx Lot.

My back end solution:

/Schem

mgmt.makePropertyKey("guid").dataType(classOf[java.lang.String]).make()
mgmt.makePropertyKey("propFoo1").dataType(classOf[java.lang.Long]).make()
mgmt.makePropertyKey("propFoo2").dataType(classOf[java.lang.Long]).make()
mgmt.makePropertyKey("propFoo3").dataType(classOf[java.lang.Long]).make()
mgmt.makePropertyKey("propFoo4").dataType(classOf[java.lang.Long]).make()
mgmt.makePropertyKey("propFoo5").dataType(classOf[java.lang.Long]).make()

In controller for Update method:

// Map of no changeable atb

val vertexEntityOld = EntityController.findByGuid(newEntity.guid.toString())
newEntity.propFoo1  = oldEntity.propFoo1 
newEntity.propFoo2  = oldEntity.propFoo2 

Upvotes: 0

Views: 50

Answers (1)

Daniel Kuppitz
Daniel Kuppitz

Reputation: 10904

Titan has the notion of static vertices; that's the only thing that comes close to what you want. But read-only properties are not supported out of the box, that's something your application code has to take care of.

Upvotes: 1

Related Questions