kurtbuilds / ormlite

An ORM in Rust for developers that love SQL.
https://crates.io/crates/ormlite
MIT License
216 stars 11 forks source link

Update Database Entry without making a new instance of the Struct #27

Closed Arthex1 closed 12 months ago

Arthex1 commented 1 year ago

Hello, I have recently started to use Ormlite. and was playing around with CRUD operations, what really annoyed me was that It created a new struct instance every time i wanted to update the database entry. So i was curious if it is possible not to do that.

kurtbuilds commented 1 year ago

Can you clarify with code what situation you're encountering this, and what the annoyance is?

Generally speaking, the database might make updates that you didn't explicitly request (e.g. triggers), so to remain accurate, the model does have to be refreshed.

Arthex1 commented 1 year ago

Can you clarify with code what situation you're encountering this, and what the annoyance is?

Generally speaking, the database might make updates that you didn't explicitly request (e.g. triggers), so to remain accurate, the model does have to be refreshed.

Basically, I have a table/schema with a bunch of properties, which therefore means a lot of getters and setters. I could always wrap my struct in another struct, and mutate the field to the newer instance of the struct whenever needed, but it gets unhygienic real quick when you have multiple tables in the database. So I choose to avoid that path.

kurtbuilds commented 1 year ago

Sorry, I'm still not getting the issue you're describing. It'd be more helpful if you directly show the problem you're encountering, and the workaround you found, with code samples.

kurtbuilds commented 12 months ago

Closing to keep things clean. If you're still encountering this, feel free to re-open with additional detail.