In Functions that are called by hooks, there is a javascript variable called "doc". "doc" is a java ODocument object:
http://orientdb.com/javadoc/latest/com/orientechnologies/orient/core/record/impl/ODocument.html http://orientdb.com/docs/last/Document-Database.html To get a property, you use the doc.field(String fieldName) method. It's the same for embedded docs. The return type varies based on the field type. Note that for graph users, this is kind of confusing b/c you need to use the Document database api instead of the graph api. However, ODocument has methods like getDirtyFields and getOriginalValue so that you can determine what is being updated in this request. You CAN use the graph api but it requires more lines of code. For example, I do the following quite a bit: var db = doc.getDatabase(); var og =(db.getTransaction().isActive()) ?new com.tinkerpop.blueprints.impls.orient.OrientGraph(db) :new com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx(db); var oe = og.getElement(doc.field('@rid')); var isV = (oe.getElementType() === 'Vertex'); var isE = (oe.getElementType() === 'Edge'); og is the graph database instance (either transactional or not depending on how the client made the call) oe is the rid of the document PS the OrientDB documentation is severely lacking in this respect. I think there is a mention of the doc variable in the documentation but I can't find it now. On Tuesday, June 21, 2016 at 10:39:45 AM UTC-4, scott molinari wrote: > > I am traveling, so I can't try it out, so I'll ask. > > All I need then is something like doc.myProperty to access a property? How > about embedded docs? > > Scott > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
