Closed Joshfindit closed 7 years ago
Thanks, that's interesting. I've never worked with UUID--what do you think is a good way to start converting the IDs? Get a series of random UUID and start plugging them in?
Yep. If you were going to convert in one fell swoop, just assign v4 (random) UUIDs to each entry in the database and accept those IDs in place of the numerical ones. Then, when the database creates a new entry, generate and store the UUID for it.
UUIDs can be generated easily in any programming language I know of as well as linux with uuidgen
(OSX has a uuidgen
command, but it doesn't follow the spec), and sites like https://www.uuidgenerator.net
There's also a discussion going on here: https://github.com/phalt/swapi/issues/74
If you're not concerned about existing integrations, the couple of code lines there look like they would switch the whole API to UUID instead of Integer id.
I just realized that ghibliapi doesn't have a database, so if you are willing to drop Integer ids, it's just a matter of changing the ids in the json file.
If that sounds ok to you and you say yes, I'll do up a pull request.
Sure, I'd appreciate it.
A pleasant surprise as an API, thank you.
UUIDs have the benefits of being globally unique, which means that if someone brings in data from an API that returns a UUID, they can use that UUID as the internal ID as well.
If IDs are returned sequentially, the API caller have to create a different ID internally and then map it to the external ID for later updates.