Background
I'm developing a Rails backend for my Swift app for the first time, and I'm wondering whether the I should store the record ID in my model. On the Swift side my architecture is basically MVVM and most of the business logic is contained to the VMs, so the models are basically DTOs in that they're Codable, but they also are used to populate views throughout the app.
Problem
So far, I'v designed the routes such that un-safe HTTP methods are references with ID's corresponding to the MySQL record ID, but I realize this would mean I would need to store the ID in the Swift model for the lifespan of the object in many cases. This isn't horrible, but I belive it would couple the database and frontend rather tightly.
Is there an alternative to this? If I decide to switch database schemas I'd prefer to only edit my *Service classes on the front end.
I'm aware that this gem exists https://github.com/norman/friendly_id , but my largest table would not enforce uniqueness on any column other than id, so I'm not sure that's a viable option.
I'm sure this question's been asked before, but I couldn't find anything.
Thanks.
Aucun commentaire:
Enregistrer un commentaire