Yes, I was running the "execute" in Studio, when I got the error and your 
explanation makes perfect sense why it won't work, now that you mention it. 
I should have realized that, while doing it.

But, with your help, I've gotten my trigger working. It's a custom function 
"setLastUpdatedAt" and is triggered on "afterUpdate" and looks like this:

var db = orient.getDatabase();

var og = (db.getTransaction().isActive())
    ?orient.getGraph()
    :orient.getGraphNoTx();

var now = new Date().getTime();

doc.field("lastUpdatedAt", now);

doc.save();
 
return;

And it works like a charm. 

Though, I would imagine Java hooks would perform better, and since this 
activity will be done as a standard part of my app, I'll probably go with a 
Java hook eventually. This get's me further though, so I can continue work. 

Thanks so much for the help. 

@ODB Team - would you consider this a good solution for creating an update 
trigger, which updates a date/time field? If yes, would you like me to add 
it to the docs under custom functions? I wish I understood more about 
digging into custom functions and using ODB's engine to work with it, I'd 
do more of a write-up in the docs. 

I feel this feature could be a wicked webinar!!!! 

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.

Reply via email to