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
- No permissions provided for action 'read...
I have a very weird error; In a function I'm using dynamic keys to perform read write operation in rows. I have the scopes for read and write rows. The funct...
- Issue with downloading large files (40GB...
Hi everyone! I am using the latest Appwrite 1.8.0 version on my self-hosted server. I successfully uploaded a large ZIP archive (~40GB) using the chunked uploa...
- Repository directory size should be less...
Whenever I create a function i get the error above. Is there a way to get around this? How do I fix this?