I'm using Appwrite Cloud with TablesDB. Calling updateRow with DB operators work as expected:
await databases.updateRow({
databaseId: 'db-id',
tableId: 'table-id',
rowId: '123',
data: {
items: Operator.arrayRemove(oldId),
},
});
await databases.updateRow({
databaseId: 'db-id',
tableId: 'table-id',
rowId: '123',
data: {
items: Operator.arrayInsert(2, newId),
},
});
But staging these updates in a transaction causes the entire items array to be set to null:
const transaction = await databases.createTransaction();
await databases.updateRow({
databaseId: 'db-id',
tableId: 'table-id',
rowId: '123',
transactionId: transaction.$id,
data: {
items: Operator.arrayRemove(oldId),
},
});
await databases.updateRow({
databaseId: 'db-id',
tableId: 'table-id',
rowId: '123',
transactionId: transaction.$id,
data: {
items: Operator.arrayInsert(2, newId),
},
});
await databases.updateTransaction({
transactionId: transaction.$id,
commit: true
});
Staging these updates via createOperations also doesn't work, but it only throws an error instead of damaging existing data:
await databases.createOperations({
transactionId: 'transaction-id',
operations: [
{
action: 'update',
databaseId: 'db-id',
tableId: 'table-id',
rowId: '123',
data: {
items: Operator.arrayRemove(oldId),
}
},
{
action: 'update',
databaseId: 'db-id',
tableId: 'table-id',
rowId: '123',
data: {
items: Operator.arrayInsert(2, newId),
}
}
]
});
The returned error is:
AppwriteException: Invalid document structure: Attribute "items" must be an array
code: 400,
type: "document_invalid_structure",
response: "{\"message\":\"Invalid document structure: Attribute \\\"items\\\" must be an array\",\"code\":400,\"type\":\"document_invalid_structure\",\"version\":\"1.8.0\"}",
Maybe I'm using DB operators wrong but documentation is limited and the typescript typings in node-appwrite are even unusable (cannot assign string Operators to columns of incompatible types). In any case, I'm surprised that this behavior isn't caught and fixed pre-release
Recommended threads
- After assigning a domain to my Dart func...
I’ve attached the images. Could anyone please explain how this execution is being performed?
- Provider not enabled in Dotnet project
# Bug Report: Appwrite .NET SDK `CreateOAuth2Token` → `project_provider_disabled` ## Issue Using **Appwrite .NET SDK (v3.1.0)**, `CreateOAuth2Token` for Googl...
- Stuck on project restoration after inact...
Hey there! My project was paused due to inactivity today. I tried to restore it, but it's completely stuck on the restoration process. Could someone please tak...