
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
- line 1: 107 Killed npm run build
When trying to deploy my Nuxt app for testing, it goes through rendering chunks successfully and once it gets to Initializing the pre-renderer it throws this er...
- Vercel Deployment issue
I am trying to deploy my web project using vercel, but in the deployed link, it is fetching some of the attributes and for the rest it is giving "not found" err...
- Failing to run document operations on sd...
Could someone point me in the right direction I'm going in cirlces. I have a problem with sdks and my self-hosted server in production (for ~3 years) I have bee...
