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
- OAuth Browser Popup doesn't close
after OAuth the browser popup doesnt close but the user is logged in, what could be the issue?
- Cannot create API key in Cloud
Console UI is blocking to create API Key for my project with "Expiration date" valeu "Never". It says: "This field is required" If i select an other option, it ...
- Please why is Appwrite permission now wo...
Suddenly the permission stopped working I canβt give permission to a collection/table anymore?