Which npm pkg to use in functions, 'appwrite' or 'node-appwrite'.
- 0
- Databases
- Functions
- Tools
- Cloud
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.
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).
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
Collection IDs are the number on the right side of the names
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.
Please post the code and errors and I'll try to help you
I have no collection ID
Collection ID should be visible on the right of table names
like such
This is an example of how some server side code created documents:
const newRoomDocRef = await this.databases.createDocument(
process.env.MASTER_DATABASE_ID,
process.env.ROOMS_COLLECTION_ID,
ID.unique(),
newRoomData
);
uses
"node-appwrite": "^17.0.0"
You can take a look at more function examples here: https://github.com/AOSSIE-Org/Resonate-Backend/
THis is my database (Support), it has one table (captcha), with a table ID but no collection id).
table ID is the same as collection ID
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
so all their attributes are the same as well
OK, I'll push up a minimum example to test it out, and report back. thanks,
Best of luck!
Recommended threads
- Auth not working on expo react native
I'm trying to launch a development server with expo go and appwrite as a backend. On my windows pc, I've got a local docker instance of appwrite running as my b...
- Urgent help required - Could not resolve...
I upgraded my production environment to 1.8.0 but experienced issues with appwrite running out of worker threads. I downgraded back to 1.6.1 and restored the da...
- createMembership is not sending email wi...
Parameters should be correct. Account and Membership are successfully created. I have a next.js project with localhost origin allowed. I checked spam etc. i...