Back

StringAttribute as array

  • 0
  • Databases
silent
12 Jan, 2024, 16:01

What is the structure required for a string attribute that is an array? I am trying a list of lists, but I keep getting an error trying to update the attribute.

TL;DR
Developers are inquiring about using a string attribute as an array in their code. One developer suggests stringifying the array and saving it as a string attribute, then parsing it when fetching. The option of using multi-dimensional arrays is also brought up. Another developer suggests passing a simple array when using the attribute string with an array checked. A code example is provided. The developer asks for clarification on the required structure for a string attribute that is an array, as they are encountering errors when trying to update the attribute.
Kenny
12 Jan, 2024, 16:10

Is it's the attribute string with array checked, I believe you'd just pass a simple array.

TypeScript
const promise = databases.createDocument(
'[DATABASE_ID]', 
'[COLLECTION_ID]', 
'[DOCUMENT_ID]', 
{
  array: ['test', 'test2', 'test3']
});
silent
12 Jan, 2024, 16:10

So, no multi-dimensional arrays?

silent
12 Jan, 2024, 16:11

It's fine if not, I can work around. Just wondering the limits.

Kenny
12 Jan, 2024, 16:20

I don't know off the top of my head, but if there isn't you can stringify your array and save it to a string attribute, then when fetching parse it?

silent
12 Jan, 2024, 16:38

Yes. I can do that.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more