0
我在流星中使用aldeed:simple-schema和Mongo集合。流星simple-schema:根據另一個字段值設置最小/最大限制
我有一個由網格(x/y座標)組成的集合。它有描述尺寸的字段和一系列點,它們不得超出這些尺寸的範圍。
我想能夠在座標上定義一個約束,以防止它們超出網格邊界。以下是我想要做的事情可能看起來像:
MyGrid.attachSchema({
gridWidth: {
type: Number,
min: 1,
max: 100
},
gridHeight: {
type: Number,
min: 1,
max: 100
},
gridPoints: {
type: [Object],
minCount: 0
},
// HERE is what I want to do
'gridPoints.$.x': {
type: Number,
min: 0,
max: gridWidth - 1 // <--- THIS
},
'gridPoints.$.x': {
type: Number,
min: 0,
max: gridHeight - 1 // <--- THIS
}
});
這樣的事情可能嗎?我沒有在簡單模式文檔中找到它,所以可能不會,但對於支持這些類型的「引用」,這聽起來並不是太牽強...