0

I'm trying to $set a multidimensional array of objects ("log") in Meteor on the server side. Every time I do the operation, the objects all appear as null after the update. I suspect it might be a problem with my SimpleSchema, but I can't find any answers on how to do it properly. At worst, since it's all generated by the server, is there any way I can just disable verification of this field entirely in SimpleSchema?

Example update:

{ $set: {
  log: [
    [
      [{
        "event": "ability",
        "sourceId": "Attack",
        "result": true,
        "timestamp": "2015-12-01T09:11:07.465Z",
        "selfId": "p2",
        "targetId": "e1"
      }, {
        "event": "effect",
        "sourceId": "dealBaseDamage",
        "result": 7,
        "timestamp": "2015-12-01T09:11:07.467Z",
        "selfId": "p2",
        "targetId": "e1"
      }],
      []
    ]
  ]
} }

And this gives the following result in the database after the operation:

"log": [
  [
    [
      null,
      null
    ],
    []
  ]
]

My schema is as follows:

log: {
  type: Array,
},
'log.$': {
  type: Array,
},
'log.$.$': {
  type: [Object],
  optional: true,
  blackbox: true
}

I've also tried this:

log: {
  type: Array,
},
'log.$': {
  type: Array,
},
'log.$.$': {
  type: Array
},
'log.$.$.$': {
  type: Object,
  optional: true,
  blackbox: true
}
anj
  • 51
  • 4
  • `log.$.$.$` is not valid, you need to refactor your way of doing this if I'm not wrong but in any case having such schema is not a good idea and you should think about doing this in different way regardless. –  Dec 01 '15 at 09:26
  • @MarkUretsky Can you elaborate on why it's not valid? I saw [this issue on GitHub](https://github.com/aldeed/meteor-simple-schema/issues/440#issuecomment-156112138) so assumed it would be possible. The schema is a system where it goes log[roundNumber][turnNumber][actionNumber] so I don't need to store that data elsewhere. Is there a reason why that's a problem? – anj Dec 01 '15 at 13:03

0 Answers0