Hello.
At the bottom of my project's console, in the footer, I have Version 1.7.4. However, when I run my server side function, I am told that databases.deleteDocuments is not a function.
Why would that be?
I have this in my package.json:
"dependencies": {
"node-appwrite": "^12.0.1"
},
deleteDocments is not a function
my full code for the function:
import { Client, Users, Databases, Query } from 'node-appwrite';
export default async ({ req, res, log, error }) => {
const client = new Client()
.setEndpoint(process.env.ENDPOINT)
.setProject(process.env.PROJECT_ID)
.setKey(req.headers['x-appwrite-key']);
const users = new Users(client);
const databases = new Databases(client);
try {
if (!req.body) throw new Error('Missing request body');
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
const userId = data?.$id;
log('userId:', userId);
if (!userId) {
throw new Error('Missing user ID in request')
};
const user = await users.get(userId);
log('user:', user);
const profileId = user.prefs?.profile_id;
log('profileId:', profileId);
if (profileId) {
await Promise.all([
databases.deleteDocuments(
process.env.DATABASE_ID,
process.env.SAVES_COLLECTION,
[Query.equal('userId', profileId)]
),
databases.deleteDocument(
process.env.DATABASE_ID,
process.env.USERNAMES_COLLECTION,
profileId
)
]);
}
await users.delete(userId);
return res.json({ success: true, deletedProfileId: profileId });
} catch (err) {
error('Failed to delete user: ' + err.message);
return res.json({ success: false, error: err.message });
}
};
12.x is very old, update to 17.x
Lmk if the issue still happens after updating.
just running npm i node-appwrite keeps it at 12. Is it safe to do npm install node-appwrite@latest --save?
Also, I used the "Quick start" to create my function. I did not create it manually. So, Quick Start installs v12
it keeps it at 12 because your package.json says to use 12
you can do npm i node-appwrite@17.2.0
sorry. I'm confused. When I use Quick Start, I do not have any json files. So how does it get 12?
Is this not in your package.json
that says to use 12
yes. This is in the file that is create via Quick Start.
I understand
update to 17 npm i node-appwrite@17.2.0
now I get Failed to delete user: Server Error
Recommended threads
- Google login on mobile not working
Hi the gg login auth in mobile not working. No error show. But the user couldnt login in Attached is the video. Desktop is working well and im using custom doma...
- Appwrite docs mcp server 502 bad gateway
I added the appwrite docs mcp server to vscode following the docs https://appwrite.io/docs/tooling/mcp/vscode#step-1 but upon start it gives the following error...
- Appwrite 1.8.1 TablesDB Permissions Issu...
Hi - I'm migrating a newer VueJS web application from Supabase to Appwrite. I'm looking for an experienced Appwrite Developer to help me solve a permissions iss...