Closed akashkumar23 closed 4 months ago
yep. I'm getting this error:
AppwriteException [Error]: Invalid query: Attribute not found in schema: senderBankId
at Client.call (webpack-internal:///(rsc)/./node_modules/node-appwrite/lib/client.js:206:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Databases.listDocuments (webpack-internal:///(rsc)/./node_modules/node-appwrite/lib/services/databases.js:1658:16)
at async $$ACTION_1 (webpack-internal:///(rsc)/./src/lib/actions/transaction.actions.ts:40:36)
at async $$ACTION_1 (webpack-internal:///(rsc)/./src/lib/actions/bank.action.ts:88:42)
at async Home (webpack-internal:///(rsc)/./app/(root)/page.tsx:39:21) {
code: 400,
type: 'general_query_invalid',
response: {
message: 'Invalid query: Attribute not found in schema: senderBankId',
code: 400,
type: 'general_query_invalid',
version: '1.5.7'
}
}
I am getting account: undefined
I've got a fix for it.
On transactions.acton.ts:
"use server";
import { ID } from "node-appwrite";
import { createAdminClient } from "../appwrite";
import { parseStringify } from "../utils";
const {
APPWRITE_DATABASE_ID: DATABASE_ID,
APPWRITE_TRANSACTION_COLLECTION_ID: TRANSACTION_COLLECTION_ID,
} = process.env;
export const createTransaction = async (
transaction: CreateTransactionProps
) => {
try {
const { database } = await createAdminClient();
const newTransaction = await database.createDocument(
DATABASE_ID!,
TRANSACTION_COLLECTION_ID,
ID.unique(),
{
channel: "online",
category: "Transfer",
...transaction,
}
);
return parseStringify(newTransaction);
} catch (error) {
console.error(error)
}
};
export const getTransactionsByBankId = async ({
bankId,
}: getTransactionsByBankIdProps) => {
try {
const { database } = await createAdminClient();
const senderTransactions = await database.listDocuments(
DATABASE_ID,
TRANSACTION_COLLECTION_ID
// [Query.equal("senderBankId", bankId)]
);
const receiverTransactions = await database.listDocuments(
DATABASE_ID!,
TRANSACTION_COLLECTION_ID!
// [Query.equal("receiverBankId", bankId)]
);
const transactions = {
total: senderTransactions.total + receiverTransactions.total,
documents: [
...senderTransactions.documents,
...receiverTransactions.documents,
],
};
return parseStringify(transactions);
} catch (error) {
console.error(error)
}
};
@ArthurDias01 do you get account: undefined , like this ?
@ArthurDias01 do you get account: undefined , like this ?
I was, just change the file like I showed in the last msg and it all worked afterwards
It worked for me!! thanks @ArthurDias01
Hi @ArthurDias01 , I can see that you removed the query from the appwrite database and the problem solved. Can you explain why / how did it work? I can also see that those sample transactions are not the part of my appwrite transactions
thanks @ArthurDias01 I was getting the same error. your solution worked.
I copied the code and i get this,
code: 404,
type: 'collection_not_found',
response: {
message: 'Collection with the requested ID could not be found.',
code: 404,
type: 'collection_not_found',
version: '1.5.8'
}
}
An error occurred while getting the account: TypeError: Cannot read properties of undefined (reading 'documents')
at $$ACTION_1 (webpack-internal:///(rsc)/./lib/actions/bank.actions.ts:89:63)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Home (webpack-internal:///(rsc)/./app/(root)/page.tsx:46:5)
GET /?_rsc=3rnhc 200 in 2810ms
Hi @ArthurDias01 , I can see that you removed the query from the appwrite database and the problem solved. Can you explain why / how did it work? I can also see that those sample transactions are not the part of my appwrite transactions
did you get the reasion why it worked after doing this???
I've got a fix for it.
On transactions.acton.ts:
"use server"; import { ID } from "node-appwrite"; import { createAdminClient } from "../appwrite"; import { parseStringify } from "../utils"; const { APPWRITE_DATABASE_ID: DATABASE_ID, APPWRITE_TRANSACTION_COLLECTION_ID: TRANSACTION_COLLECTION_ID, } = process.env; export const createTransaction = async ( transaction: CreateTransactionProps ) => { try { const { database } = await createAdminClient(); const newTransaction = await database.createDocument( DATABASE_ID!, TRANSACTION_COLLECTION_ID, ID.unique(), { channel: "online", category: "Transfer", ...transaction, } ); return parseStringify(newTransaction); } catch (error) { console.error(error) } }; export const getTransactionsByBankId = async ({ bankId, }: getTransactionsByBankIdProps) => { try { const { database } = await createAdminClient(); const senderTransactions = await database.listDocuments( DATABASE_ID, TRANSACTION_COLLECTION_ID // [Query.equal("senderBankId", bankId)] ); const receiverTransactions = await database.listDocuments( DATABASE_ID!, TRANSACTION_COLLECTION_ID! // [Query.equal("receiverBankId", bankId)] ); const transactions = { total: senderTransactions.total + receiverTransactions.total, documents: [ ...senderTransactions.documents, ...receiverTransactions.documents, ], }; return parseStringify(transactions); } catch (error) { console.error(error) } };
I assume that worked because we have no bank information yet, but not sure and just thank u for providing this code
I am not getting the list of sample transactions ? Do any one facing the same issue ?