Meteor:将null插入数据库的多维对象数组(SimpleSchema)

时间:2015-12-01 09:16:41

标签: javascript meteor meteor-collection2 simple-schema

我正试图在服务器端的Meteor中$set多维对象数组(“log”)。每次执行操作时,对象在更新后都显示为null。我怀疑它可能是我的SimpleSchema的问题,但我找不到任何关于如何正确执行它的答案。在最坏的情况下,由于它全部由服务器生成,有什么办法可以完全禁用SimpleSchema中对该字段的验证吗?

更新示例:

{ $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"
      }],
      []
    ]
  ]
} }

这在操作后在数据库中给出以下结果:

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

我的架构如下:

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

我也试过这个:

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

0 个答案:

没有答案
相关问题