You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. We are trying to use hanami-model in a non standard way, and we are running into some issues. I'd like to see if we're using it the wrong way, we are missing something, or simply hanami-model was never intended to be used like this.
We are basically writing an app that will listen to some network events, and persist them into a database for further processing. The unorthodox behaviour here is that the actual primary keys of the records we want in the database are given to us by these events, and therefore we don't need (nor want) the database to use an autogenerated id field to keep track of those.
So in our implementation, we'd like to receive an event, create an entity for that event that has a custom uuid field that is part of the message, and persist that in the database using that uuid as the entity identity.
In order to achieve that we've tried several things, but none of them seem to have worked for us. Find below a link to a gist with the final configuration we've ended up with:
We'd appreciate some feedback on this approach. If it's something that is definitely not supported by the gem, or if we are simply not configuring it properly. Also, if this is a usage scenario you would consider supporting in the future.
If that doesn't work, we'll have to end up having an id field in the DB and use that as a primary key, and then add some extra logic in our repositories to track duplicates. However, in doing so, I think we'd lose a lot of the work hanami-model repositories give us out of the box.
Many thanks.
The text was updated successfully, but these errors were encountered:
It looks like a lot has changed since then, we moved to a different schema to allow both our own uuid and the autogenerated one, so it may not be worth investigating this anymore.
Hopefully when the move to ROM has been officially released I'll be able to revisit this.
Hi. We are trying to use
hanami-model
in a non standard way, and we are running into some issues. I'd like to see if we're using it the wrong way, we are missing something, or simplyhanami-model
was never intended to be used like this.We are basically writing an app that will listen to some network events, and persist them into a database for further processing. The unorthodox behaviour here is that the actual primary keys of the records we want in the database are given to us by these events, and therefore we don't need (nor want) the database to use an autogenerated
id
field to keep track of those.So in our implementation, we'd like to receive an event, create an entity for that event that has a custom
uuid
field that is part of the message, and persist that in the database using thatuuid
as the entity identity.In order to achieve that we've tried several things, but none of them seem to have worked for us. Find below a link to a gist with the final configuration we've ended up with:
https://gist.github.com/brafales/2619eea7418d8dbb89b7dd245a401332
We'd appreciate some feedback on this approach. If it's something that is definitely not supported by the gem, or if we are simply not configuring it properly. Also, if this is a usage scenario you would consider supporting in the future.
If that doesn't work, we'll have to end up having an
id
field in the DB and use that as a primary key, and then add some extra logic in our repositories to track duplicates. However, in doing so, I think we'd lose a lot of the workhanami-model
repositories give us out of the box.Many thanks.
The text was updated successfully, but these errors were encountered: