React Developer
Problem Summary
I'm building a React Native app with Expo and trying to create profile documents in Appwrite when users sign up. I keep getting this error:
Error: [AppwriteException: Document with the requested ID already exists. Try again with a different ID or use ID.unique() to generate a unique ID.]
What I'm doing:
Using ID.unique() to generate document IDs for profiles
Creating accounts successfully (that part works)
Trying to create profile documents in a collection called "profiles" (using the collection name, not a UUID)
The error happens even with ID.unique() generated IDs
Key detail: I'm using the collection name "profiles" as the endpoint rather than a UUID collection ID, because I think that's what the newer Appwrite version wants.
Code:
const profile = await databases.createDocument(
config.databaseId,
config.profilesCollectionId, // This is "profiles"
ID.unique(), // 20-char unique ID
{
authID: user.$id,
username,
displayName: displayName || "",
email: user.email,
}
);