
ID.unique()
indeed returns unique()
.
This when passed when creating a new document tells the server to generate a new ID for you. so in the response you would get the generated Id

thanks I'll give it a try.
I did try inserting ID.unique() , and "unique()" directly into the createDocument() but neither worked.

actually, that's what I already had and it didn't work

i must be doing something silly - i'll try again

I'm facing this issue now. I wanted to create a user and a document with the same id, is that possible to really generate a unique id on the format that appwrite uses to I can reuse it?

when you create a new user, it returns a a user model response. It contains the Id. Now you can use the same id to create a new document

Thanks @Maniac_Fighter. If I don't have the id created yet, how can I set the permissions of a document when creating it on the server? How can I use the same id on all <id> placeholders on the below code
return await databases.createDocument(database, collectionUsers, <id>, {
<id>,
email,
name,
}, [
Permission.read(Role.user(<id>)),
Permission.write(Role.user(<id>)),
]);

First you create the user with id="unique()" and the backend will replace this with the ID which you use in your subsequent createDocument call.
return await databases.createDocument(database, collectionUsers, ID.unique(), data={"user_id" = user["$id"]}) ```
Recommended threads
- Image Loading issue in Snapgram project
Hello community, I have a issue with the Image Loading I made a Project from youtube of Snapgram, it worked perfectly 8 months ago, but now the images aren't l...
- No Targets Created For Email OTP Users
I use OTP for my users. All emails are verified. No one has their email as a target. What am I doing wrong? The documentation says the targets should be created...
- Retrieving user access token on client s...
I am trying to retrieve the user token from the cookies, but they are HTTP-only and can not be accessed. Is there a way to extract the user token from the cooki...
