why it says `Document with the requested ID already exists` when i try to create documents in bulk
- 0
- Databases
- Web
as the title suggests, I'm trying to create some documents in bulk. it's successfully creating the first two, but after that, it's throwing Document with the requested ID already exists. the attachment shows my code for creating docs. I think it's something that I've done wrong. otherwise, it wouldn't follow this "complete first two only" pattern. but I don't have any idea how to even debug it. I've tried console.log(ID.unique()), but it's only printing "unique" as a string. I can't find any flaw in my code as well. and even if my code has some issues, why it's saying Document with the requested ID already exists. the ID creation part is handled by appwrite with ID.unique(). isn't?
console.log(ID.unique()) should return unique() with the parentheses
Can you try to change the first row to such
const { ID } = import('appwrite')
Yes, unique() is a special keyword for the Appwrite server.
Do you have a unique index on your collection?
you're correct. i had an unnecessary unique index on my collection. and the bug was solved after I deleted the index. but I wonder, what was happening under the hood
it's a misleading error message. we throw a duplicate document error because of the unique index but the error message says it's a duplicate ID.
what's this duplicate document error and why does this exists
because you had a unique index
no no. what I'm asking is, what issue actually appwrite was facing under the hood? when these duplicate document errors are created? I'm just curious cuz I didn't understand what was happening behind the scene, in my case
Recommended threads
- API key without database.read/write
I had some issues with my previous API key and I deleted it then I wanted to create a new one and discovered the database checkbook has no database.read/write j...
- dynamic key missing scopes for database ...
Here are the scopes listed, I get permission errors for reading row and document. Appears to be missing since last time i checked. Database 6 Scopes policies....
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?