Hey, I am trying to create a basic server function in nodejs that just makes a collection in the database with a unique id.
How would I import id using the same method i have used to import the other modules that you can see in the attachment.
Thanks
If all you want to do is create a new collection with a unique ID, you can do this
let client = new api.Client();
let database = new api.Databases(client);
client
.setEndpoint('[ENDPOINT-HERE]')
.setProject('[PROJECT-ID]')
.setKey('[API-KEY-HERE]')
const promise = databases.createCollection('[DATABASE_ID]', ID.unique(), '[NAME]');
ID.unique() is a helper function that comes with the appwrite SDK, which generates a unique ID for you.
Reference: https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesCreateCollection
If you need something more than just this, let me know!
with your import it would be api.ID.unique()
Recommended threads
- Broken Appwrite can’t make functions nor...
Hii guys, I was having this issue with my locally hosted Appwrite, I can’t create functions ( both template and manual), I can’t make a custom domain ( like in ...
- Tips for Debugging Appwrite Functions Lo...
Hi everyone! 👋 I have an Appwrite Function running locally with Docker, but I’m struggling to debug it because execution doesn’t reach the breakpoints I set. ...
- AttributeError: 'Context' object has no ...
I'm getting an error executing my function. I'm not able to replicate this locally since I have to use a mock context. Is there a way to debug this kind of erro...