How do I add an Integer column

Hi, I want to use the following command to create a new Integer column. But the following command failed. If I change the “type” to “String”, it works. So, if I want to add an Integer column, how should I modify my command? Thanks

curl -X PUT
-H “X-Parse-Application-Id: xxxxxxxxxx”
-H “X-Parse-Master-Key: xxxxxxxxxx”
-H “Content-Type: application/json”
-d ’
{
“className”: “Game1”,
“fields”: {
“uid1”: {
“type”: “Integer”
}
}
}’
http://localhost:1337/parse/schemas/Game1

Try type number ----

@uzaysan Thanks. If I want to add a double column, what should I put in the “type”? I tried “Double”, it did not work.

There is no double, float or integer in JavaScript. They are all number. There is bigInt for really large integers. But i don’t think parse supports that.

@uzaysan I see. But if a value is bigger than the range of an integer, what should I do? Create two integers? This is not an elegant solution.

Largest number in Js is Number.MAX_SAFE_INTEGER which is 9007199254740991. Are your numbers bigger than this? Maybe you should store your number as string to prevent any problems.

Edit: Mongodb supports 64bit numbers. See https://docs.mongodb.com/v4.4/core/shell-types/#numberlong But parse server doesnt specify this and mongodb create number fields with 32bit integer type. If your numbers are really bigger than 32bit maybe you should store them as string. Then when you fetch this string you can use BigInt like this:

const myNumber = BigInt(“985462154878741”)

but Ive never used BigInt so ım not sure about the behaviour.

@uzaysan postgres only supports integer up to 2147483647. But this is big enough for my app.
However, Parse does not allow me to save double or float is really a problem. For example, to save 0.013, I have to multiply this number by 1000: 0.003*1000=13 and save 13. Then, convert it back when I read it. This is not very convenient.

I just tried to insert a decimal number(2.458) and ıt worked. Can you modify a number field from dashboard and check? You can also check field type with pgadmin and change it to decimal. I dont have much experience with postgresql. But a quick google search showed me that its possible. maybe there is somehing with the parse server postgresql adapter. let me check.

@uzaysan Parse already have a postgres adapter built in. Parse has a file to convert MongoDB commands to Postgres commands. So, I feel Parse only supports MongoDB natively.

Seems like postgress adapter turns number into double presicion. See parse-server/PostgresStorageAdapter.js at alpha · parse-community/parse-server · GitHub

And double presicion takes 15 digits. Since max number (2147483647) is ten digits, you should be able to store at least 5 digits after decimal point. For example 2147483647.12345, if your number is less then 2147483647, for example 456, you should be able to store 12 digits (456.123456789101) after decimap point. Did you tried to save a decimal number? How do you save your object?