have you tried this once? https://appwrite.io/docs/client/databases?sdk=web-default#databasesGetDocument
I don't understand fully about your question but feel free to point me in a different direction
Votes
0
Replies
24
Participants
Unknown
Messages
25
have you tried this once? https://appwrite.io/docs/client/databases?sdk=web-default#databasesGetDocument
I don't understand fully about your question but feel free to point me in a different direction
Rank 2: Process
Yes, I have tried the getDocument method. But let's say instead of settings I have a orders array with order ids as strings. I fetched the main document that contains all the order ids. Now to get the order details I will have to run getDocument inside a for loop for every order id. This is a lengthy way.
If I was using Mongoose with MongoDB then I can use the Mongoose populate method to do this without extra effort.
You can get more details on the mongoose populate method here - https://www.geeksforgeeks.org/mongoose-populate-method/
id: "48hfdf9py74p9rfw", name: "Vishal Lohar", orders: [ "uiosuf89476r945r", "uiosuf876r945r", "uosuf876r945r"]}```Moderator
What you are looking is relationships: https://appwrite.io/docs/databases-relationships
Be aware, this feature is currently in beta and do not support making queries for child documents
Rank 2: Process
Yes, Any information on stable version of relationships?
Moderator
I haven't seen any information in the repository about relationships for the next version 1.4, so I think it may have improvements in 1.5, sadly I don't have any information about dates
Rank 2: Process
Okay👍
aha, now I get it after reading the blog.
Relationships yes, but, are restricted to a max depth of three levels.
Rank 2: Process
Yes, I tried and it needs a lot of improvements. Beta version is not suitable for my project.
Rank 2: Process
@joeyouss I have a doubt!
I will use your relationships doc example.
await databases.updateDocument(
'marvel',
'movies',
'spiderman',
{
title: 'Spiderman',
year: 2002,
reviews: [
'review4',
'review5'
]
}
);
If I want to add new reviews to the movie then how can I do it?
In the code example, it will just remove the old reviews relationship and will add review4, and review5 relationship.
In the end, I will just have 2 reviews.
But what if I have to add 3 new reviews? Will I have to pass all the reviews in my request body?
Moderator
You have to pass all he reviews again, probably you have to make a new call to get the current document and then push the new element and update it
Rank 2: Process
Don't you think if I have a thousand reviews then the payload size will be too big?
Rank 2: Process
Appwrite should add a method that can be used to add new items in the relationship without passing all the previous items. Something like passing permission while creating document.
Moderator
I agree with you, and it should one method to remove an element too, there are a lot improvements to do in relationships
Rank 2: Process
Yes, Right! This is the reason I am not using this feature.
Rank 2: Process
I guess, I can create a feature request for this
Moderator
That would be good, I haven't seen a request for this
Rank 2: Process
Okay, I will create one request for this feature
Rank 2: Process
https://github.com/appwrite/appwrite/issues/5925 - Please let me know if my description is not clear. I can make some edits
Can we close this in favor of https://github.com/appwrite/appwrite/issues/2531?
Rank 2: Process
What do you want to close? Github Issue or this support post
The GitHub issue you created
And then you can 👍 the GitHub issue I linked
Rank 2: Process
Alright, You can link both issues if possible. And then close mine
[CLOSED] How can I populate the database fields automatically like mongoose?