Back

Unable to change order of items in a document array attribute

  • 0
  • Databases
  • Web
Vishal Lohar
5 Aug, 2023, 05:29

Hi, I am building a web application that allows the user to change the order of items stored inside a document array attribute.

Now when I pass the new array with updated order then it doesn't work. Appwrite doesn't update the order of array items inside the document.

Also, Please note I am using document relationships.

Document Example.

TypeScript
//User
{
   name: "Vishal",
   posts: [ //Relationship with a posts collection
     "post 1",
     "post 2",
     "post 3"
   ]
}

Is there any way I can change the order of posts in the above example?

TL;DR
User is experiencing difficulty changing the order of items in a document array attribute. They are using document relationships and have provided an example of their document structure. They are seeking a solution to change the order of the posts in the provided example. No solution is provided in the thread.
Vishal Lohar
5 Aug, 2023, 05:30

Unable to change order of items in a document array attribute

Drake
5 Aug, 2023, 08:35

You're passing an array of document IDs?

Vishal Lohar
5 Aug, 2023, 08:55

No, i am passing the entire document

Vishal Lohar
5 Aug, 2023, 10:38

Payload and Response Example.

Drake
5 Aug, 2023, 14:45

This is an update document API call? Can you copy and paste the JSON here?

Also, can you share the details of the collections so we know all the attribute configurations?

Vishal Lohar
7 Aug, 2023, 03:43

These are the profile collection attributes

Vishal Lohar
7 Aug, 2023, 03:43

I have a unique profile for each user and I am updating the profile everytime anything changes

Vishal Lohar
7 Aug, 2023, 03:44

Links Collection Attributes

Vishal Lohar
7 Aug, 2023, 03:49

I have removed some data like createdAt and UpdatedAt to just have some imp fields

Drake
7 Aug, 2023, 04:19

Can you provide the details of the links attribute?

Vishal Lohar
7 Aug, 2023, 04:32

@Steven Please check this

Drake
7 Aug, 2023, 04:40

I meant the details of the attribute in the profile collection. So I can see the type of relationship and whatnot

Vishal Lohar
7 Aug, 2023, 04:42
Drake
7 Aug, 2023, 05:11

I'll have to try and reproduce this tomorrow

Drake
7 Aug, 2023, 22:48

okay so i was sort of able to reproduce the problem...the order was off even when i created the document and the order was incorrect, but it wasn't incorrect the same way yours was...

would you be able to create an issue for the problem?

Vishal Lohar
8 Aug, 2023, 13:03
joeyouss
8 Aug, 2023, 13:46

thank you for opening

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