Hi guys, I found another user with similar issue but he recreated the collection. I don't want to go this path since that is very time consuming.. my issue is that I can garantee that I am trying to create the documents with different keys using ID.unique() and it works only for the first document of my collection. if Itry a second document with a different id but and different unique field it does not work. I've tried to remove my unique key on my field cnpj and the error persist. Using nextjs.
this is my code:
try {
const incomingData = await req.json();
incomingData.cnpj = parseInt(incomingData.cnpj, 10);
const document = {
...defaultDocument, // Default values
...incomingData // Overwrites with the values from the request body
};
const document2 = {
cnpj: document.cnpj,
razao_social: document.razao_social
}
console.log(document);
const uniqueId = ID.unique();
console.log("Generated Unique ID:", uniqueId);
const documentCreeated = await databases.createDocument(
databaseId,
collectionId,
uniqueId,
document2
);
return NextResponse.json({ success: true, documentCreeated });
} catch (error) {
return NextResponse.json({ success: false, error: error.message, details: error }, { status: 500 });
}
this my my two calls, the first called when collection is empty.
Did you imported ID from appwrite?
Yes I did.
POST /api/cnpj 500 in 822ms
{
cnpj: 12333,
razao_social: null,
email: null,
nome_fantasia: null,
...
}
Generated Unique ID: 671aa813002c760d0676
POST /api/cnpj 200 in 819ms
{
cnpj: 1233399,
razao_social: null,
email: null,
nome_fantasia: null,
...
}
Generated Unique ID: 671aa82600313179d157
POST /api/cnpj 500 in 832ms
this is my logging showing the id is different on each save
that is so weird, even via cloud it error
This should be the case 🤔
yeh at least that is consistent 🙂
I have no indexes atm.
Mine works fine. Can you show the document that already exist?
Like ss
you want to see the json?
No I wanted to see the id
Can you just try to test with another collection?
If the issue persist?
I will create a new one, but it very time consuming to create collection thought the UI. 😦
I will create with just two fields to test
it did work now. . like the other user who had same issue.
that seems like a bug somewhere
Hope i dont run into this issue in middle of development🙏
lol me too. I am just starting using iti and if that breaks down the road will be painful
anyway thanks for the help @Axistro
@Kenny
Recommended threads
- Appwrite taking too much space
hi, i have a self hosted instance of appwrite on a vps. my appwrite db has around 50k documents in total but appwrite is taking up more then 120+GB. i doubt the...
- Realtime for specific collection
```dart void _subscribeToSubmittedMediaAppend() { final realtime = Realtime(client); realtimeMediaValidationSubscription = realtime.subscribe( [...
- Weird issue when creating document