Skip to content
Back

deleteDocments is not a function

  • 0
  • Tools
  • Functions
  • Web
  • Cloud
Los Feliz
6 Aug, 2025, 21:37

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:

TypeScript
  "dependencies": {
    "node-appwrite": "^12.0.1"
  },
TL;DR
Issue: Error message 'deleteDocments is not a function' while running the server-side function. Confusion about package version. Solution: Update to version 17 of node-appwrite by running `npm i node-appwrite@17.2.0` to access the `deleteDocuments` function. This should resolve the mentioned error.
Los Feliz
6 Aug, 2025, 21:39

deleteDocments is not a function

Los Feliz
6 Aug, 2025, 21:41

my full code for the function:

TypeScript
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 });
  }
};
Kenny
6 Aug, 2025, 21:41

12.x is very old, update to 17.x

https://www.npmjs.com/package/node-appwrite

Kenny
6 Aug, 2025, 21:42

Lmk if the issue still happens after updating.

Los Feliz
6 Aug, 2025, 21:47

just running npm i node-appwrite keeps it at 12. Is it safe to do npm install node-appwrite@latest --save?

Los Feliz
6 Aug, 2025, 21:49

Also, I used the "Quick start" to create my function. I did not create it manually. So, Quick Start installs v12

Kenny
6 Aug, 2025, 21:49

it keeps it at 12 because your package.json says to use 12

Kenny
6 Aug, 2025, 21:50

you can do npm i node-appwrite@17.2.0

Los Feliz
6 Aug, 2025, 21:50

sorry. I'm confused. When I use Quick Start, I do not have any json files. So how does it get 12?

Kenny
6 Aug, 2025, 21:51
Kenny
6 Aug, 2025, 21:51

Is this not in your package.json

Kenny
6 Aug, 2025, 21:51

that says to use 12

Los Feliz
6 Aug, 2025, 21:51

yes. This is in the file that is create via Quick Start.

Kenny
6 Aug, 2025, 21:51

I understand

Kenny
6 Aug, 2025, 21:51

update to 17 npm i node-appwrite@17.2.0

Los Feliz
6 Aug, 2025, 21:57

now I get Failed to delete user: Server Error

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more