inaka / sumo_db

Erlang Persistency Framework
http://inaka.github.io/sumo_db/
Apache License 2.0
174 stars 37 forks source link

Wrong event when persisting #241

Closed HernanRivasAcosta closed 8 years ago

HernanRivasAcosta commented 8 years ago

If you call sumo:persist and the data to persist already has an id, sumo just assumes it's updating, not creating it. As seen here, it fires an event according to this logic.

elbrujohalcon commented 8 years ago

@HernanRivasAcosta can you fix the link? It's pointing to an unrelated line in code.

ferigis commented 8 years ago

In order to avoid overhead, the fix should be to send the event "persisted" when users creates or updates an entity

ferigis commented 8 years ago

@llamallamaduck since you have been working with those events, what do you think about this change?

llamallamaduck commented 8 years ago

It seems ok to me if there is no other way of knowing whether the thing is updated or stored for the first time. Is there any other way to get that information?

I was using these for the wombat plugin, and changing this will not have too much impact on its code. On the other hand, I do not know how useful is it for the user to know whether the thing was newly created or just updated? I am guessing it would be nice to know though.