Is it possible to create a data collection as an array of strings instead of an array of objects wit

default discord avatar
6 months ago

Is there a way to generate a data collection that is an array of strings, for example:

interests: ["interest one", "interest two", ...]

instead of an array of objects as it currently is:

interests: [{"id": "1234", "value": "interest one"}, {"id": "1235", "value": "interest two"}, ...]


  • default discord avatar
    6 months ago

    How about JSON?

    There may be a better way than JSON

    But alternatively, you could hook into the field hooks

    And either format the field, or save to a field that is formatted as you want

  • default discord avatar
    6 months ago

    Is there a reason to not just use => i.value);

    in your frontend to receive an array of strings?

  • discord user avatar
    Payload Team
    6 months ago

    i agree with everything above, but one other note, we are planning to add

    hasMany: true

    to the


    field at some point in the future as well, which will allow for an array of strings

    but right now we don't support that

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.