【发布时间】:2017-09-24 10:42:03
【问题描述】:
我正在尝试在 node-simple-schema 中定义 GeoJSON 架构以在我的应用程序中使用。
我正在尝试定义位置、线串、衬线和多边形数组,以便稍后在定义点、线串、.. 几何图形时使用它们。
这是我现在正在做的,但它不起作用。
const Position = new SimpleSchema({
position: {
type: Array,
label: 'A single position. ...',
minCount: 2,
maxCount: 3,
},
'position.$': {
type: Number,
label: 'A number representing...',
},
});
const Point = new SimpleSchema({
type: {
type: String,
label: 'The type of the feature.',
allowedValues: ['Point'],
},
coordinates: {
type: Position.pick('position'),
// this does not work either
// type: Position.getObjectSchema('position'),
label: 'A single position',
},
});
当我尝试像这样进行验证时,我得到一个错误。
const PointExample = {
type: 'Point',
coordinates: [180.0, 46.5, 100],
};
Point.validate(PointExample);
【问题讨论】:
标签: node.js meteor geojson simple-schema