I'm trying to create a document from my appwrite function with and it works perfectly fine when i execute the function in local, but in production function instead of creating document and giving the new document response it is giving me the document list,
Whats the code? Maybe also post the error logs if available.
no it gives success reponse, but the reponse contains all the document list instead of the new document
can you show some relevant code?
this is when i execute local function
this is when i execute remote function
this is the code
const { user } = req;
const { db } = appwriteClient(req, res);
const requiredFields = ['documentOf', 'documentType'];
const {
documentOf,
entityId,
documentType,
identifiedBy,
identificationNo,
VIN,
description,
category,
status,
amount,
address,
issuedBy,
issuedDate,
expiryDate,
renewalDate,
notes,
fileIds
} = req.body;
if (!user || !user.id) {
return res.json({ message: "User ID is required" }, 400);
}
for (const field of requiredFields) {
if (!req.body[field]) {
return res.json({ message: `${field} is required` }, 400);
}
}
const newData = {
documentOf,
entityId: entityId || null,
documentType,
identifiedBy: identifiedBy || null,
identificationNo: identificationNo || null,
VIN: VIN || null,
description: description || null,
category: category || null,
status: status || null,
amount: amount || null,
address: address || null,
issuedBy: issuedBy || null,
issuedDate: issuedDate || null,
expiryDate: expiryDate || null,
renewalDate: renewalDate || null,
notes: notes || null,
fileIds: fileIds || [],
userId: user.id.toString()
};
const response = await db.createDocument(Env.dbId, Env.collectionId, ID.unique(), newData);
return res.json({ message: "Document created successfully", document: response }, 201);
please use 3 backticks to format the code
its done
are you using cloud or self hosted? whats the sdk version used?
i'm using the package called @darShan/appexpress for express like routing in appwrite function
lol thats my library. but I mean what appwrite sdk? appwrite, node-appwrite and the version.
wow, i think i met the right guy for my error
the latest version is 14.1.0 for node-appwrite. can you check if that helps. different errors on same code is tricky. Also, remove the node_modules and then do a npm install for a clean init.
lol the @ name automatically updated to your name
also the appexpress version is pretty outdated too.
i don't think this issue is due to appexpress
indeed.
do you know any other pakage for suggestion which is better than appexpress?
I am biased but any other package that support custom view engines [HBS, PUG, JSX, TSX, etc], has middleware and http web compression support, not that I know of. But there were a few hono like adapters I think. Maybe check #🛠│tools or #🎪│showcase.
also, did you try updating the node sdk version as I suggested above?
Recommended threads
- Realtime doesn't seem to work with Table...
Hi, I am trying to connect my tables rows with realtime on my react website, it connects, but I dont get the rows when a row is being created. I tried with Chan...
- Failed to receive appwrite reset passwor...
Hey there, I forgot my password for my appwrite account but when i use forgot password, i dont get an email to reset the account but when i try to create a new ...
- Excessive usage of cloud functions is sl...
I have made almost all my requests through cloud functions and jwt , due to security fears of a user editing a field he is not supposed to . This unfortunately...