How to Best Store Array Data?

Hi, I’d like to know if there is any available field combination or best practice approach for storing array data? An example use case would be storing music album genres. When adding a new album document I’d like our editors to be able to use a multi-select to add multiple genres as metadata to be pulled out and displayed on the frontend.

I’ve tested a couple ways, but each has its own set of complications.

First, I could store the genres as a group of select fields:

genres: {
  type: "Group"
    value: [
      {
        genre: {
          type: "Select",
          value: "indie"
        }
      },
      {
        genre: {
          type: "Select",
          value: "pop"
        }
      },
      {
        genre: {
          type: "Select",
          value: "rock"
        }
      }
    ]
}

Pros: editors are only allowed to enter predetermined text
Cons: getting this data into a usable state on the frontend takes a bit of re-mapping, UI is a bit awkward for editors because of multiple select dropdowns, allows inputting of duplicate genres


Another approach was to just store all of the genres in a single text field:

genres: {
  type: "Text",
  value: "indie, pop, rock"
}

Pros: less verbose data structure, a bit easier to get to the data I want
Cons: editors can input any text they want leading to bad data, need to use string manipulation to get data back into an array for use on the frontend


Maybe this should be a feature request, but using a multi-select and representing the data as an array would be ideal. I’ve represented this idea below:

genres: {
  type: "Multi-Select",
  value: ["indie", "pop", "rock"]
}

Pros: editors are only allowed to enter predetermined text, easy to reuse within frontend code, less verbose data structure
Cons: none?

Any help is appreciated. Thank you for your time!

Maybe the other hack is you can create one to many relationships between Album & Genre?

But I’d love if we can have multi select that can store array!

Like the above post mentioned regarding one-to-many relationships, I believe that what I would do to model this sort of content would be to use a Group field with a Select field inside of it.

This would maintain data integrity (people wouldn’t be able to enter their own text) but also allow for adding multiple genres (from a pre-determined list). I think I personally would also just allow for duplicate genres in Prismic and then simply filter out repeated ones when displaying on the front-end.