Like what we’re doing? Star us on GitHub!

Is there an Array string in Payload CMS?

2 months ago
2 2

Hi, I tried to read the documentation, but I couldn't find it. Is there something to save array string to database?
I just want save array of strings
Ex: ["a","b","c"]
I don't want save array of objects like this, just need array of strings here

  • jacobsfletch
    Payload Team
    last month

    Thejson field might work for you:

  • JessChowdhury
    Payload Team
    2 months ago

    Hi @IRediTOTO, this isn't currently supported but would definitely be useful in many cases. This question was also discussed on discord here. A potential workaround solution would be to:

    1. Create a hidden preferences field
    2. On save, map the original array and return as an array of strings
    3. Pass this new array to your hidden field

    There might be more appropriate workarounds too if you want to share more information on what you're looking to achieve, let us know if you need further help here!

    3 replies
    2 months ago

    Thank you for replied me and let me know. Ok fine, but I will wait for a that feature like that. This pretty basic, I think any Payload newbie will ask himself: where is the array??? :D

    last month

    Payload newbie here, I think this could be really useful.

    Payload Team
    last month

    The json field might work for you:

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More