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
- HTTP POST to function returning "No Appw...
Hi everyone, I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNC...
- Can't add dart 3.5 runtime
Modified the `.env` to enable dart 3.5 runtime on my self-hosted instance but still can't find the runtime when creating a new function. I manually pulled the i...
- How to verify an user using AppWrite Fun...
I have seen similar questions but none whose solutions serve me. I have a function to verify a user with their secret and their id: https://blahblah.appwrite.gl...