
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.
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"}'
}

Does more than one record share a postId?

Ohh that was why!

Thank you SO much

[SOLVED] Row with requested ID doesn't exists, but Appwrite says it exists.
Recommended threads
- no. of rows selection
give option to select no. of rows to list per page
- 1.7.2 Node-appwrite createDocuments from...
Am I correct in my testing that functions with document creation event, wont trigger on calling createDocuments from within a function.
- Access to encrypted string attributes fr...
Can I use the getRow functionality if that row contains encrypted string attributes? Or is this completely impossible to get the value on the client side? From ...
