Data type for money

Is it safe to use float for storing money? Or is there any equivalent of Java’s BigDecimal?

Yes, but What worries you? (update: Actually technically I was wrong to say that. Isn’t totally safe)

No, but there’s discussion about it.

https://github.com/dgraph-io/dgraph/issues/926

https://github.com/dgraph-io/dgraph/issues/2107

I come from Java/MySQL, and usually it’s bad idea to story money value in floating point for reasons mentioned in e.g. floating point - Why not use Double or Float to represent currency? - Stack Overflow and floating point - storing money amounts in mysql - Stack Overflow

Do you think it’s different in Dgraph?

1 Like

Dgraph should support BigInts. There should be an issue for it. If not, feel free to file one. CC: @francesc.

Actually this issue is already there. Anyone interested in this feature please show your support there.
Add more arguments to corroborate and also, give some nice thumbs up :+1:
https://github.com/dgraph-io/dgraph/issues/2107

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.