I have a collection that is related to the user account so it has a userId
attribute that I use to store the user's ID. A user should only have one record for this collection but I can't seem to make this userId
attribute the primary key for the collection. It always creates a document ID that I need to reference. I know that I can always get the document first by searching the userId
- and then use the document ID from there to update the values of the document but I was hoping there would be a better way to do this.
What you can do is to set the document ID as the user ID and then you have the primary key uses the user ID.
Oh you mean when I create the document, instead of using ID.unique()
, I'll use the user ID instead.. I don't know why I didn't think of that. Thank you!
Does that solves your issue?
Yes it does. It was my bad for not thinking of such a simple solution.
Great! 😁
[SOLVED] How to update a document without knowing the document ID?
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...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...