
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
- Error importing data after server migrat...
Hello, I recently purchased a new web server and when trying to migrate my data from the old server to the new (both self-hosted instances of appwrite on coolif...
- Not Able to Reach Cloud
When I open the appwrite cloud I am getting error. Can you help please?
- REST API does not work for queries
``` curl -X GET "https://cloud.appwrite.io/v1/databases/<db-id>/collections/<c-id>/documents" -H "X-Appwrite-Project: <project-id>" -H "X-Appwrite-Key: <key>"...
