#[SOLVED]how to array list in appwrite attribute
142 messages · Page 1 of 1 (latest)
Afaik, the return value might be a String. You'll have to convert it into an array first.
show your code
what does cartItem attribute say?
also, can you tell me if cartItem is always a number?
It returns all the document from addtocart collection
cartitems are array list
well cartitems is expecting a string and you're not giving that
so cartItem is an array in your code right?
yes
line 288 returns this data
.
could you send an image of all attributes in there?
this
This is addtocart collection
expand this
which attribute
just the first object in that array
okay
This data returned by line 288
this is from createDocument yeah?
no
from where then?
huh
i mean no need, but listDocuments shouldn't give you this error
are you sure it's from listing?
yes
could you lower this size?
u mean array size
In the appwrite instance :/
You see this?
Go here, delete the attribute and recreate it with a lower size
deleting would cause the attributes data to be lost, right?
correct
yes
but his listing does not work at all, so my guess is it's empty
it is not empty
you could male a second collection
inside the array there is data
in appwrite?
yes
do you need that data? or can you recreate it
then just delete that attribute and recreate it with a lower size
the n what will be the further process
why?
i need to do that again
that's why
let me send you my code screenshot okay
okay or not
I mean, sure, but i doubt i can do anything with it
cannot do anything with this
i think you need to do this, try it out
make a new collection with dummy documents also works
bro you messing thing up
assuming you are getting the error here?
you cannot come with proper solution
he said listDocuments
is giving him the error lol
.
only the issue is that when i try to place the cartitem parameter value
and the error occur
so his entire code does not matter, just that aopwrite has a connection and it's fetching
so it's when creating a document then?
yes
exactly
due to cartItem value

a get method has nothing to do with what the type is as long as the data type matches the attribute type.
which is in the form of an array
apparently it's his createdocument.. bruh
i don't think he knows himself 😂
yupp. my man said listDocs as issue hence this lot of confusion.
yep
let me see the screenshots.
which one
hang on a minute.
i'll check all uploaded here, wait a few mins. pl.
okay
cartItem is an array in your code, right?
yes
and it seems its an Object of a custom type and not string.
and just need that array list to orderItem database collection
how do I do that
guide me through solution
please
each object inside your array must be converted to a string I guess.
Where you're using createDocument the value for cartItem needs to look something like this:
cartItem: [JSON.stringify(cartItem)]
the stringify might actually be it
From what I can tell, it looks like you're trying to insert an entire object into a string[], you'll just need to remember to use JSON.parse() when fetching that cartItem data later
yess
If the cart item objects are more than just strings, OP is better off using relations.
atleast the exact structure would be maintained.
Relationships could work here as well, definitely! Could even just reference an ID of another document if you wanted to wait until relationships were out of beta
This is true, referencing the ID is a go to as I've had the whole collection freezing sometimes when an item with relations is deleted.
lol
Yeah, I've had some performance issues with relationships in the past so I tend to stick with just using IDs until it's out of beta
same
@quasi light Did Ryan's fix resolve your issue?
Yes it worked
Great!
Would you mind marking it as solved by adding [SOLVED] to the beginning of the title?
Have an appwrite day!
but one issue is there
What's up?
check this message