I would like to create a comments section and store the comments as follows:
TypeScript
[
{
"name"='',
"comment"='',
"created"= Date.now()
}
]
and later would like to get the data as comments[0]?.name. I would like to store this as an array in the appwrite document. Is this possible?
Summary
The user wants to know if an Appwrite array can have multiple objects inside. The answer is yes, you can have an array of strings in posts and put the document IDs of the related comments. Alternatively, you can put the ID of the post in the comment and fetch all the comments for that post. In Appwrite 1.3, built-in support for relationships was added, but the Appwrite cloud is currently on version 1.1.2. The user wants to create a comments section and store the comments as an array in the appwrite document. This is possible.
Drake
Admin
May 28, 2023, 15:43
Are you on Appwrite Cloud?
Drake
Admin
May 28, 2023, 15:44
I highly recommend creating a collection of comments.
RangerDev
Rank 3: Container
May 28, 2023, 16:05
yes
RangerDev
Rank 3: Container
May 28, 2023, 16:05
Ok... but how am I supposed to link that to the documents?
RangerDev
Rank 3: Container
May 28, 2023, 16:06
like
RangerDev
Rank 3: Container
May 28, 2023, 16:06
each ducmunet in the posts will also have a document in the comments
RangerDev
Rank 3: Container
May 28, 2023, 16:06
but how am I supposed to like the,?
RangerDev
Rank 3: Container
May 28, 2023, 16:06
like in supabase
Drake
Admin
May 28, 2023, 16:27
In Appwrite 1.3, we added built-in support for relationships. Unfortunately, Appwrite cloud is currently on version 1.1.2.
Drake
Admin
May 28, 2023, 16:28
For now, you can have an array of strings in posts and put the document IDs of the related comments.
Or you can put the ID of the post in the comment and then you can fetch all the comments for that post.