Skip to content
Back

[SOLVED] Row with requested ID doesn't exists, but Appwrite says it exists.

  • 0
  • Databases
lucas
10 Oct, 2025, 15:34
TypeScript
async function test() {
    try {
        const input = {}
        const extracted = Object.values(input).map(item => ({
            $id: item.postId,
            postId: item.postId,
            uniqueId: item.uniqueId
        }));

        const queueResponse = await tables.listRows({
            databaseId: "data-database-id",
            tableId: "queue-table-id",
            queries: [
                Query.equal("$id", extracted.map(item => item.postId)),
                Query.limit(100)
            ]
        });
        console.log("Existing posts fetched:", queueResponse);

        for (const row of extracted) {
            const response = await tables.listRows({
                databaseId: "data-database-id",
                tableId: "queue-table-id",
                queries: [
                    Query.equal("$id", row.postId)
                ]
            });
            console.log(`${extracted.indexOf(row)}th postId Exists: ${response.total > 0}`);
        }

        const createResponse = await tables.createRows({
            databaseId: "data-database-id",
            tableId: "queue-table-id",
            rows: extracted.map(item => ({
                $id: item.postId,
                postId: item.postId,
                uniqueId: item.uniqueId
            }))
        });
        console.log("New posts created:", createResponse);
    } catch (error) {
        console.error("Error in test:", error);
    }
}
test();
TL;DR
A developer encountered an issue where Appwrite claimed that a row with a requested ID existed when it didn't. The problem was due to multiple records sharing a postId. The solution was to ensure unique IDs or use ID.unique() to generate one.
lucas
10 Oct, 2025, 15:35
TypeScript
`PS C:\> node tablesTest.js
Existing posts fetched: { total: 0, rows: [] }
0th postId Exists: false
1th postId Exists: false
2th postId Exists: false
3th postId Exists: false
4th postId Exists: false
5th postId Exists: false
6th postId Exists: false
7th postId Exists: false
8th postId Exists: false
9th postId Exists: false
10th postId Exists: false
11th postId Exists: false
12th postId Exists: false
13th postId Exists: false
14th postId Exists: false
15th postId Exists: false
16th postId Exists: false
17th postId Exists: false
18th postId Exists: false
19th postId Exists: false
20th postId Exists: false
21th postId Exists: false
22th postId Exists: false
23th postId Exists: false
24th postId Exists: false
25th postId Exists: false
Error in test: AppwriteException: Row with the requested ID already exists. Try again with a different ID or use ID.unique() to generate a unique ID.
    at _Client.call (file://node_modules/node-appwrite/dist/client.mjs:294:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async test (file://tablesTest.js:132:32) {
  code: 409,
  type: 'row_already_exists',
  response: '{"message":"Row with the requested ID already exists. Try again with a different ID or use ID.unique() to generate a unique ID.","code":409,"type":"row_already_exists","version":"1.8.0"}'
}
Kenny
10 Oct, 2025, 15:40

Does more than one record share a postId?

lucas
10 Oct, 2025, 15:44

Ohh that was why!

lucas
10 Oct, 2025, 15:47

Thank you SO much

Kenny
10 Oct, 2025, 15:50

[SOLVED] Row with requested ID doesn't exists, but Appwrite says it 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