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
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Appwrite cloud DB server error 500
Getting this error
- appwrite indexes not working (?
i have this index: ``` "indexes": [ { "key": "single-user-per-event", "type": "unique", ...