Appwrite relationships are great. I have a relationship with one to many. So one Document stores multiple ids. But is there a way to (programatically) reorder this list?
Not sure what exactly you mean. Do you want to re-order the way they're returned?
yep. For example, that the current 3rd value is becoming the 2nd.
So you want to keep the order of the relationships the way they are inserted? Or if you edit them from the other side into:
artictleBlocks: [id1, id2, id3], to have them returned in that order? And if you add a new block id4 that is linked to the Article to be added at the end, resulting in id1, id2, id3, id4?
I'm not sure of how relations fully work, but I'm pretty sure that the order of the IDs in the relationship are chronological. So whenever a child is created, it gets attached to the end of the list. I'd like to assume that's the expected behaviour, as you can filter/sort your lists on the client side
why would you like to do it? order generally doesn't have any impact
Yeah, they are returned based on their creation time. I was testing it now.
I guess he wants to keep them in his defined order, without needing a special attribute for it such as having on each ArticleBlocks attribute int order.
Aha that makes sense. @Tomic R. you should look at this idea of using an integer attribute order to help you sort them better.
Recommended threads
- createCollection Deprecated
- All My Project is Gone
Hello everyone, please help. Why have all my projects suddenly disappeared? I received a warning via email about one of my projects being paused. When I clicked...
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...