Best practice for storing/handling enumerations in MeteorJS?


Say you have a model with a field that has a set of valid values (I.e. enumeration).

For example, you have a Person model (document), and they have a Rank field, which can be (captain, major, private).

In a RDBMD-based framework, you might store the values in a separate lookup table and refer to them.

My question is, in Meteor, what are best practices around how you should store them, and how you use them?


It is no different in Meteor world. Your options are more or less the same:

  1. Store on mongodb and join (if the values are likely to get updated)
  2. Store in meteor settings and load with app
  3. Store in a global (or namespaced) variable
  4. Store in a variable within the method/function that assigns the ranks to the person documents
  5. Store within the schema definition if you are using simple schema

It does not make much difference just because this is Meteor really. What matters is the application design tailored towards the specific requirements of that app.

That being said, I would go easy on joins and lookups and this is still also a valid argument with any database technology but a slightly bigger concern with mongodb.


also good to know about freeze