Hello! I have tried to create a document but I keep getting the following error in my nodejs function
"UserEmailHere (role: users) missing scope (databases.read)"
I still get this error after creating the database and collection and setting permissions for the collection to "All Users". I also used the .setJWT(jwtToken). The collection ID is "1"
Here is my code: const db = await database.createDocument("databaseIDHere",'1',ID.unique(),{ 'clockIn':Date.now(), 'clockOut':Date.now()+new Date(2023,12,2,15), 'userId':user.$id }) return res.json(JSON.stringify({ db }))
Thanks in advance
The solution is new Date(Date.now()). Everything in appwrite was correct. I just got the Date code messed up. I set the type on the collection to be a Date type. Date.now() returns a number
[Solved] Cannot Create Document
The key thing is to send a iso formatted string. I guess JavaScript converts date objects to that automatically
Thank you
Recommended threads
- Cloud Function Deployment Issue – Timeou...
Impossible to deploy a function for more than an hour. My project ID is: 69cc7a82000b42b8f5e2 Here's the error I get after waiting 15 minutes: Synchronous funct...
- Dart runtime functions are timing out an...
My appwrite function is not executing at all and showing the error in error logs: I tried redeploying. Still no luck. I have set the function to ise maximum re...
- Event-triggered function executes but pr...
Hello! I'm running self-hosted Appwrite 1.9.0. I have a Dart function (tried both dart-3.5 and dart-3.10 runtimes) with these events configured: ```teams.staff...