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
- After assigning a domain to my Dart func...
I’ve attached the images. Could anyone please explain how this execution is being performed?
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a