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
- Project paused?
Hello, I have two Appwrite projects and I can not resume them for some reason. I'm using the free plan, and I saw in the pricing page that 2 free projects are a...
- Python TablesDB Rework
Hi, i starting to rework some older functions to TablesDB list_rows Method. I used list_documents with a resultset with worked fine. Now i tried to get all rows...
- HUGE OUTRAGE IN APPWRITE, I CANNOT ACCES...
I have 2k users trying to access, sending me messages. What am I supposed to do? Please solve this asap.