Use array with string as values / schemas

Not sure if my doubt is directly related with this, maybe it goes in other direction but I just found some info and I’d like to clarify some points.

I have to add another field in my Food collection for each plate:

rating: {
    votes: [],
    score: 0

I need to add the Meteor.userId() in the array but as index:
rating.votes['CAdsAcvaSADd'] = 3

I have no idea how to do this with Mongo. That’s why I thought that I’d need to define some schemas to say I want votes: [String]. (LINK)

  • Would I need to specify this in the schema then?
  • In terms of best practiques is this a better solution/way?

My app is also AngularJS with TypeScript.

Thanks in advance

why not use an object for votes, instead of an array, and use the userId as a key?

Yes, that’s what I did at the end. Easier to understand too, you right.

But I found this info about schemas and I was wondering to myself if it would be better in terms of best practiques to use this in my app (votes: Object in this case, yes).

But to be honest I have nothing related with this in my architecture and everything works well.