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
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...
- Inquiry: How to Reduce Cold Start Durati...
Hey! I was using Python for the function runtime, but after reading that Go has the fastest runtime, I switched my code over to Go. However, I'm still seeing co...
- After a GET request is passed to functio...
Create execution in the console can normally retrieve the get parameters。WHy?