默认情况下,声明为数组的属性接收默认的空数组以供使用。MongoDB已经开始验证geojson字段,并大喊空数组。解决方法是在架构中添加一个预保存钩子,以检查这种情况并首先修复文档。
schema.pre('save', function (next) { if (this.isNew && Array.isArray(this.location) && 0 === this.location.length) { this.location = undefined; } next();})


