I have VERTEX class and I would like to automatically update field with timestamp (DATETIME) on every that record data change.
Thank you guys.
Hi @petervavro
You can do it with a hook, see
https://orientdb.com/docs/3.0.x/internals/Dynamic-Hooks.html
https://orientdb.com/docs/3.0.x/java/Java-Hooks.html
Thanks
Luigi
Thank you,.. But can I use Dynamic Hooks in Vertex class ?
Sure, there is no limitation in terms of document types
But in my case, I am already extending the vertex class :
e.g. : CREATE CLASS MyVertexClass EXTENDS V
So, if I understand right to be able to use Dynamic Hooks I need to extend the class following way : CREATE CLASS MyVertexClass EXTENDS OTriggered
And that is changing the type of class to "Generic Class" and it is not Vertex anymore right ? Is this proper ? Or how to do this please ?
Thank you
Hi @petervavro
OrientDB supports multiple inheritance since v 2.1, see https://orientdb.com/docs/2.2.x/SQL-Alter-Class.html
Thanks
Luigi
@luigidellaquila , I really appreciate your help and patience.
Thanks to your help, I was able to come up with solution, so here it is :
CREATE FUNCTION updateDT "doc.field('fieldNameDT', new Date().getTime());" LANGUAGE Javascript
CREATE CLASS MyClass IF NOT EXISTS EXTENDS OTriggered;
ALTER CLASS MyClass CUSTOM onAfterUpdate='updateDT';
But in my case I had to extend EDGE class so instead CREATE CLASS MyClass IF NOT EXISTS EXTENDS OTriggered; use :
CREATE CLASS MyClass IF NOT EXISTS EXTENDS E;
ALTER CLASS MyClass SUPERCLASS +OTriggered;
Thanks
Most helpful comment
@luigidellaquila , I really appreciate your help and patience.
Thanks to your help, I was able to come up with solution, so here it is :
But in my case I had to extend EDGE class so instead
CREATE CLASS MyClass IF NOT EXISTS EXTENDS OTriggered;use :Thanks