Closed beebase closed 8 years ago
Yeah, unfortunately there's no support for triggering events from stuff that happens in a query. Theoretically, it would be possible to trigger 'afterSave', since neo4j can send back information about what the result of an api call is, but it's hard to see how that could be reliably used to tell if it was indeed this model that was updated.
As for validation and prepare, that's unfortunately out of the question. The only way I could see to do it would be to parse the cypher query inside seraph-model... and that's a little bit outside the scope of the project.
In your example, I would suggest that you first use Model.save
to create your Song
, and thereafter relate it to the user. You could also use a composition, depending on the context.
I'm trying to create a new Song that should be linked to a logged in existing user. The query itself works fine but doesn't trigger the prepare event on the Model (=Song) Is this a bug or is my approach wrong? Should I create the Song first (Model.create) and then the relation to the existing user?
(BTW, the prepare is working ok , when updating a song)