Back

why int attribute in appwrite accepts numbers as a String ?

  • 1
  • Databases
  • Cloud
jesus
12 Mar, 2024, 14:56

Hi, Just a question...

I've set the AMOUNT attribute type as an intger in appwrite, why it accepts Strings ?

If i pass the number as String like this "5000" appwrite accepts it !!

TypeScript
        'DatabaseId,
        'CollectionId',
        {
            "AMOUNT": "50000"
        }
    );```

When using a function event to listen to any create and print the req.body the AMOUNT appears as String ?

Why the create document doesn't throw an error ?
TL;DR
Developers are wondering why the 'int' attribute in Appwrite is accepting numbers as a string. Even when passing a number as a string, such as "5000," Appwrite doesn't throw an error and accepts it. This behavior occurs when using a function event to listen to creations. Solution: Appwrite is accepting numbers as strings due to how the Data API handles inputs. To ensure that the attribute is treated as an integer, developers should explicitly convert the string input to an integer before passing it to the 'AMOUNT' attribute.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more