
Hi, I'm happy to discouver just a few moment how to initialize database with function. 🙂
I occured a dfficult: How do I set default date in DateTime field with function
databases.createDatetimeAttribute(
prodDb.$id,
contractColl.$id,
'start_date',
true,
Date.now().toLocaleString()
);
throw this error
AppwriteException [Error]: Invalid `default` param: DateTime::__construct(): Failed to parse time string (1,694,626,509,410) at position 0 (1): Unexpected character
at Client.call (/usr/local/server/src/function/node_modules/node-appwrite/lib/client.js:172:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Databases.createDatetimeAttribute (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/databases.js:528:16) {
code: 400,
type: 'general_argument_invalid',
response: {
message: 'Invalid `default` param: DateTime::__construct(): Failed to parse time string (1,694,626,509,410) at position 0 (1): Unexpected character',
code: 400,
type: 'general_argument_invalid',
version: '1.4.2'
}
}

Use this instead
databases.createDatetimeAttribute(
prodDb.$id,
contractColl.$id,
'start_date',
true,
(new Date()).toISOString()
);

It's generate the same error

The message should be different Can you share it?

Let me take my computer

There's another thing you should check is that the default can't be set when the field is required https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesCreateDatetimeAttribute



just now

Yes, Now is the second error

Either change the 4th parameter to false

Or remove the default

It seems like you can't set both

let try

You are strong, it's work

I've the same error with enum now. So I want to know:
When we set default value, we always set required to false ?*

Yes, Think of it that way if the user must enter a value the default value would never be in use

It's correct, I edit my code. Now all work without warning

It's my first quick mistake solved 🙂

[Solved] Set current date to DateTime with function

@Binyamin , I will open new issue for explain if you are for explication

On what part?

difference between set permission to collection or to a query (Permission and Document Security)

Is this a new thing? When setting permission to a collection only then each user request to that collection will be check against the collection permission table But if you also add document permission then it will check against both of them And if **one **of them is good for the current user then the that user will get access to that document in the collection.

That is my case, 'ADMIN (one person)' are king, He can do anything but user can edit only the files that related to their company
Recommended threads
- I am facing this error: type 'Null' is ...
When attempting to fetch areas from the area collection, the application throws an error: "type 'Null' is not a subtype of type 'int.'" This issue originates in...
- Adding Domain to Sites [Self Hosted]
I am struggling to get this working. I stood-up a new server and deployed appwrite 1.7.4. I added update .env file _APP_DOMAIN=appwrite.mydomain.com _APP_DOMAI...
- Need help migrating from self hosted to ...
Hi! I am using self hosted appwrite for testing stuff out and now it's prod ready I want to deplot it to the cloud version. It gave me this error when fetchin...
