I have a Post collection with reference to User collection using userId. When I get all post, is there a way to automatically get user's details as well for each post? Im using Client SDK and Cloud.
Not for now (it's not available in the self-hosted version as well) For this use case it will be a bit complex
- either move the whole logic to a cloud function (which can be overwhelming)
- make a sequential request to get user details
Hey @Binyamin , if I install server SDK and set the relationship programmatically. Will it work for my use case?
Im about to try this. But As I read your reply, would like to double check. https://appwrite.io/docs/databases-relationships#create-in-code
Relationship won't work as you're working with the cloud
I see... I need self-hosted for it to work? What combination of AppWrite tools or setup would you suggest so I can create a complex App with AppWrite?
Do you have links to some repo that implements complex CRUD using React/Next? Would really appreciate it. π
Some features Im looking to try to implement with Appwrite:
- Posts with image and user info (CRUD) - there will be a lot of posts so creating new request to get user info for each post might not be ideal.
- Saved posts
- User groups
Notes:
- In self hosted you'll solve only the for the first part, the relationship, but for the second part - user to collection relationship this is not available right now in any version.
- If you need to connect posts to author collection, then in this case I would recommend going with self-hosted or wait for the cloud to support relationships.
- For the React part I recommend checking the react at awesome-appwrite
Structure:
You can do something like this.
Create another users collection, in add all of your user details, create a function that will get trigger each time new user is created or edited, then you can update that users collection with ease.
In the posts collection add user_id
relationship field of many to one to the users collection.
For user groups the best would be to use Appwrite teams
I see gotcha! Thanks @Binyamin π
Hey @Binyamin if I go this path - "make a sequential request to get user details", will I hit request limit? I encounter request limit last time. Im not sure if this type of request is not counted on that.
You'll probably hit it yes. To avoid that you'll have to use function
Recommended threads
- self-hosted auth: /v1/account 404 on saf...
Project created in React/Next.js, Appwrite version 1.6.0. Authentication works in all browsers except Safari (ios), where an attempt to connect to {endpoint}/v1...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...