我正在尝试运行mongoose document.save但是我收到以下错误:
TypeError: Object #<Object> has no method 'test'
at model.matchValidator (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schema\string.js:221:16)
at SchemaType.doValidate (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schematype.js:627:28)
at Array.forEach (native)
at SchemaString.SchemaType.doValidate (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schematype.js:614:19)
at Document.validate.err (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\document.js:956:9)
at process._tickCallback (node.js:415:13)
我正在使用sails框架,但是我使用不运行sails的迁移模块运行它,所以基本上我只是调用自己的bootstrap(相当于app.js但不启动整个框架,只是我的自己的代码)。
问题是,当我尝试在我的一个迁移脚本中创建document.save时,我得到了上一个错误,因为以下代码:
猫鼬/ LIB /模式/ string.js
SchemaString.prototype.match = function match (regExp, message) {
// yes, we allow multiple match validators
var msg = message || errorMessages.String.match;
function matchValidator (v){
return null != v && '' !== v
? regExp.test(v)
: true
}
this.validators.push([matchValidator, msg, 'regexp']);
return this;
};
当我看一下regExp时,它只是一个只有 proto 的对象,仅此而已。 我不知道问题出在哪里,当我正常运行我的应用程序时,它能正常工作吗?