Back

[SOLVED] Create document with unique() id and no unique indexes throws document_already_exists

  • 0
  • Databases
obiwanzenobi
5 Sep, 2023, 21:26

no - everything is ok with my relationships - here is data

TypeScript
{
   "name":"Współczesność – o epoce",
   "onlyForPremium":false,
   "isMediaPremiumOnly":false,
   "mainMedia":"https://vimeo.com/855166568",
   "mediaType":"video",
   "mediaSource":"vimeo",
   "mediaThumbnail":"64f5c6fef098d9d485d8",
   "mediaContent":"64f5c6ff0ce0bb1785b0",
   "slug":null,
   "createdBy":null,
   "createdById":null,
   "updatedBy":null,
   "updatedById":null,
   "oldTitle":null,
   "oldAuthor":null,
   "oldCategory":null,
   "preview":"word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word",
   "metaTitle":null,
   "metaDescription":null,
   "metaKeywords":null,
   "zdayId":"29005",
   "content":[
      
   ],
   "contentIds":null,
   "oldId":null,
   "assignedToCategories":[
      "64f79cced50f0fee7825"
   ],
   "search_name_zdayId":"Współczesność – o epoce 29005"
}
TL;DR
A user was trying to create a document with a unique ID and no unique indexes but encountered the error "document_already_exists." They discovered that the error was caused by a one-to-one relationship between the documents. The solution was to remove the relationship or add a unique index. However, the user suggested that there should be an error log to identify which unique parameter is causing the failure.
obiwanzenobi
5 Sep, 2023, 21:30

this is interesting

obiwanzenobi
5 Sep, 2023, 21:43
TypeScript
            65 Query    START TRANSACTION
            65 Query    INSERT INTO `appwrite`.`_1_database_1_collection_19`
                (`name`, `onlyForPremium`, `isMediaPremiumOnly`, `mainMedia`, `mediaType`, `mediaSource`, `mediaThumbnail`, `mediaContent`, `slug`, `createdBy`, `createdById`, `updatedBy`, `updatedById`, `oldTitle`, `oldAuthor`, `oldCategory`, `preview`, `metaTitle`, `metaDescription`, `metaKeywords`, `zdayId`, `contentIds`, `oldId`, `search_name_zdayId`, `_createdAt`, `_updatedAt`, `_permissions`, _uid) VALUES ('Współczesność – o epoce', 0, 0, 'https://vimeo.com/855166568', 'video', 'vimeo', '64f5c6fef098d9d485d8', '64f5c6ff0ce0bb1785b0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word', NULL, NULL, NULL, '29005', NULL, NULL, 'Współczesność – o epoce 29005', '2023-09-05 21:40:15.225', '2023-09-05 21:40:15.225', '[]', '64f7a03f3663e31c0619')
            65 Query    ROLLBACK
obiwanzenobi
5 Sep, 2023, 21:44

removing relationship doesn't change anything

obiwanzenobi
5 Sep, 2023, 21:47

shouldn't be there some error log that points out which unique parameter is failing? like unique _uid

Drake
5 Sep, 2023, 21:49

ya we need to improve that error

Drake
5 Sep, 2023, 21:49

what collection is that? _1_database_1_collection_19 is it supposed to be inserting? I don't think so, right?

obiwanzenobi
5 Sep, 2023, 21:50

how to check that? collection name is content_entry

Drake
5 Sep, 2023, 21:51

but content is blank here 🧐

obiwanzenobi
5 Sep, 2023, 21:51

yes. empty list for that one

obiwanzenobi
5 Sep, 2023, 21:59

same for content null

TypeScript
{
   "name":"Współczesność – o epoce",
   "onlyForPremium":false,
   "isMediaPremiumOnly":false,
   "mainMedia":"https://vimeo.com/855166568",
   "mediaType":"video",
   "mediaSource":"vimeo",
   "mediaThumbnail":"64f5c6fef098d9d485d8",
   "mediaContent":"64f5c6ff0ce0bb1785b0",
   "slug":null,
   "createdBy":null,
   "createdById":null,
   "updatedBy":null,
   "updatedById":null,
   "oldTitle":null,
   "oldAuthor":null,
   "oldCategory":null,
   "preview":"word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word",
   "metaTitle":null,
   "metaDescription":null,
   "metaKeywords":null,
   "zdayId":"29005",
   "content":null,
   "contentIds":null,
   "oldId":null,
   "assignedToCategories":null,
   "search_name_zdayId":"Współczesność – o epoce 29005"
}
obiwanzenobi
5 Sep, 2023, 22:03
obiwanzenobi
5 Sep, 2023, 22:03

inside appwrite sdk - documentId is unique for sure

obiwanzenobi
5 Sep, 2023, 22:03

ok i found something

obiwanzenobi
5 Sep, 2023, 22:03

when creating document with the same values

obiwanzenobi
5 Sep, 2023, 22:04

1:1 data - it cannot be created event if there is no unique index

obiwanzenobi
5 Sep, 2023, 22:17

ok found it

obiwanzenobi
5 Sep, 2023, 22:17

this is caused by a one to one relationship

obiwanzenobi
5 Sep, 2023, 22:17

and I'm trying to assign manytoone

Drake
5 Sep, 2023, 22:34

the assignedToCategories?

obiwanzenobi
5 Sep, 2023, 22:35

mediaThumbnail

obiwanzenobi
5 Sep, 2023, 22:35

and mediaContent

obiwanzenobi
5 Sep, 2023, 22:36

message was just a litle bit misleading

obiwanzenobi
5 Sep, 2023, 22:36

thanks for help!

obiwanzenobi
5 Sep, 2023, 22:36

[SOLVED] Create document with unique() id and no unique indexes throws document_already_exists

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more