Basic Countries collection

I’m new to strapi, I just run the docker to play around. Using strapi 3.6.3

I want to model “Countries” with 2 fields like this:

  • isoCode: The ISO 3-letter code, like for example “EGY” for Egypt or “THA” for Thailand. Unique. Regexp: ([A-Z]{3})
  • name: Localized, for example “Egypt” in English, “Egipte” in Catalan and “Egipto” in Spanish. Also unique.

I don’t want an “autonumeric ID” to be created. I want the isoCode to be the key.

And I don’t want Strapi to insist in the isoCode to be “localized” as it is a key, not a value.

How can I do it?

I had the similar thing that I wanted to do.
I made the collection and then in the service and in boostrap.js I created a function to fetch data from
https://restcountries.eu/

Then extract it and add it to the database : )

Well, my goal was not “the countries”, but to learn “how to make a custom Id”. I could change the question for example to say:

“I have a model with Hotels with id, name and description, and I need the id to not be autonumeric but to be x or y text that I generate in my model OUTSIDE the Strapi thing. The description needs to be localized.”.

The question is more about Strapi model/configuration than “the countries content”.

PD: Thanks for the tip, though, about the countries API :smiley:
PD2: Maybe I should change the title to “How to create a non-localized custom ID field + a localized text field” but IDK how to change the title…

Oh i see
Well i think you can override the controller, then return the data you want :slight_smile:
meaning you can then return the id as what you want it to be? :slight_smile:
Just a thought tbh but there is info about that here.