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
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...