In my nodejs/mongo/mongoose application the users are associated with different codes. these are 3 letter codes, like ABC, XYZ, ACD, etc. each person can have zero to max 20 codes like that. a sample data would look like this:
[
{name: John, codes: 'abc, bbb, dyd, zzz'},
{name: Sammy, codes: 'haz, rty, dyd'},
{name: Suzanne, codes: 'abc, ccc, mnm, zzz'}
]
when i search for people, i search for those codes. for example: find me all the people with code 'abc' (and have other properties).
The question: how to store the users codes data for best performance? in a simple string like in my example? different rows with id's and index? and how to query for people with a specific code in mongoose?
there can be millions of people, and not that many codes, maybe 30 altogether, and each person will have between 0 and 10 or 20 codes.