Skip to content
Back

Which npm pkg to use in functions, 'appwrite' or 'node-appwrite'.

  • 0
  • Databases
  • Functions
  • Tools
  • Cloud
LSM
13 Nov, 2025, 11:14

I've been successful in creating users in a function with the node-appwrite package, but I'm trying to interact with databases. But there is no "TablesDB" class - it is in the other pkg. Also, some examples ask for a collection id, I see no collection id for my tables - just a table name. I have the latest npm pkg. I've gone through docs but the examples are conflicting or use pre-ES6 "require" and look old. Does anyone have a good working FUNCTION example (using ES6 imports) that interacts with appwrite database/tables (insert/read) I'd appreciate it. Thanks.

TL;DR
Developers are confused between 'appwrite' and 'node-appwrite' npm packages. The concept of TablesDB API uses tables and rows instead of collections and documents. For interactions with databases/tables, 'appwrite' package should be used. A code example for creating documents in a function using ES6 imports is provided in the original message.
LSM
13 Nov, 2025, 11:37

I also find the concept of table vs collection confusing. The server api docs refer to creating and working with collections and documents, but nothing about working with tables and rows (which is how the tables are designated).

M4dhav
13 Nov, 2025, 11:38

Can't help with the npm package issue, but as far as the TablesDB API is concerned, a collection is now a Table, and each Document is now a Row

M4dhav
13 Nov, 2025, 11:39

Collection IDs are the number on the right side of the names

LSM
13 Nov, 2025, 11:40

OK thanks. But the issue remains, I have no collection ID. If you look here https://appwrite.io/docs/references/cloud/server-nodejs/databases#createDocument I have tried to repurpose this example to use in a function, but it does not work. I will post the code and errors.

M4dhav
13 Nov, 2025, 11:41

Please post the code and errors and I'll try to help you

M4dhav
13 Nov, 2025, 11:41

I have no collection ID

Collection ID should be visible on the right of table names

M4dhav
13 Nov, 2025, 11:41

like such

M4dhav
13 Nov, 2025, 11:42

This is an example of how some server side code created documents:

TypeScript
const newRoomDocRef = await this.databases.createDocument(
         process.env.MASTER_DATABASE_ID,
            process.env.ROOMS_COLLECTION_ID,
            ID.unique(),
            newRoomData
        );
M4dhav
13 Nov, 2025, 11:43

uses "node-appwrite": "^17.0.0"

M4dhav
13 Nov, 2025, 11:44

You can take a look at more function examples here: https://github.com/AOSSIE-Org/Resonate-Backend/

LSM
13 Nov, 2025, 11:45

THis is my database (Support), it has one table (captcha), with a table ID but no collection id).

M4dhav
13 Nov, 2025, 11:46

table ID is the same as collection ID

M4dhav
13 Nov, 2025, 11:47

The change from Collections/Documents API to the TablesDB API is just decorative, and Tables directly correspond to Collections and Rows directly correspond to Documents

M4dhav
13 Nov, 2025, 11:47

so all their attributes are the same as well

LSM
13 Nov, 2025, 11:47

OK, I'll push up a minimum example to test it out, and report back. thanks,

M4dhav
13 Nov, 2025, 11:47

Best of luck!

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