Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Error Creating Document with Datetime attribute #66

Open
2 tasks done
destocot opened this issue Dec 21, 2023 · 3 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@destocot
Copy link

destocot commented Dec 21, 2023

馃憻 Reproduction steps

 const document = await databases.createDocument(
    import.meta.env.VITE_APPWRITE_EVENTS_DATABASE_ID,
    import.meta.env.VITE_APPWRITE_EVENTS_COLLECTION_ID,
    ID.unique(),
    {
    ...,
    date: new Date().toISOString(),
    ...
    }
  );

My Solution: If I remove the Z at end of datetime, document is then correctly created

 const document = await databases.createDocument(
    import.meta.env.VITE_APPWRITE_EVENTS_DATABASE_ID,
    import.meta.env.VITE_APPWRITE_EVENTS_COLLECTION_ID,
    ID.unique(),
    {
    ...,
    date: new Date(target.date.value).toISOString().slice(0, -1),
    ...
    }
  );


馃憤 Expected behavior

New document in collection will be created.

馃憥 Actual Behavior

Gives a 500 server error

image

馃幉 Appwrite version

Version 0.10.x

馃捇 Operating system

Linux

馃П Your Environment

No response

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@destocot destocot added the bug Something isn't working label Dec 21, 2023
@stnguyen90
Copy link
Contributor

stnguyen90 commented Dec 22, 2023

@destocot, thanks for creating this issue! 馃檹 Were you using the web sdk or node SDK?

Also, what version of the SDK?

@stnguyen90 stnguyen90 self-assigned this Dec 22, 2023
@destocot
Copy link
Author

destocot commented Dec 22, 2023

@stnguyen90
apologies for any confusion but it was the

web sdk | "appwrite": "^13.0.1",

@stnguyen90
Copy link
Contributor

@destocot, sorry for the delay. I just tested with version 13.0.1 of the SDK with code like:

      let promise = databases.createDocument('default', 'test', 'unique()', {
          'dt': new Date().toISOString(),
          'searchAttribute': 'a new task',
      });

and this worked fine for me:
image
image
image

What's the payload tab look like for you in your browser's dev tools?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants