Enum values in Couchbase. string or integer?
Question
When storing enum like properties in couchbase, which is the preferred option and why ?
- are there any performance considerations ?
- how about code maintenance and re-factoring ?
should it be saved as: { color : 'red' } or { color : 1 }
Solution
{ color : 'red' } or { color : 1 }
Always do color: red
in the database.
Reasons:
- When you add a new enum value you don't need to be careful of the 'index'
- Self documenting : there is no confusion what
red
means.
Also. The same should be done in your web API's.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow