我的应用经常因该错误而崩溃。 TypeError: SimpleSchema is not a constructor at attendances.js (imports/api/attendances/attendances.js:44:27)
。我已经用谷歌搜索,而StackOverflow解决方案不起作用。我正在运行simpl-schema和Collection2,有人可以告诉我这里有什么问题吗?
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
const Attendances = new Mongo.Collection('attendances');
Attendances.debug = true;
Attendances.allow({
insert: () => true,
update: () => true,
remove: () => true,
});
Attendances.deny({
insert: () => false,
update: () => false,
remove: () => false,
});
const AttendancesSchema = new SimpleSchema({
createdAt: {
type: Date,
},
}, {
clean: {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
getAutoValues: true,
},
});
Attendances.attachSchema(AttendancesSchema);
export default Attendances;
这是我终端中的完整错误消息。
路径:ERROR MESSAGE
W20180620-21:07:11.542(10)? (STDERR) TypeError: SimpleSchema is not a constructor
W20180620-21:07:11.542(10)? (STDERR) at attendances.js (imports/api/attendances/attendances.js:44:27)
W20180620-21:07:11.543(10)? (STDERR) at fileEvaluate (packages/modules-runtime.js:339:7)
W20180620-21:07:11.543(10)? (STDERR) at require (packages/modules-runtime.js:238:16)
W20180620-21:07:11.543(10)? (STDERR) at publications.js (imports/api/userProfiles/server/publications.js:1:354)
W20180620-21:07:11.543(10)? (STDERR) at fileEvaluate (packages/modules-runtime.js:339:7)
W20180620-21:07:11.543(10)? (STDERR) at require (packages/modules-runtime.js:238:16)
W20180620-21:07:11.543(10)? (STDERR) at register-api.js (imports/startup/server/register-api.js:1:195)
W20180620-21:07:11.543(10)? (STDERR) at fileEvaluate (packages/modules-runtime.js:339:7)
W20180620-21:07:11.544(10)? (STDERR) at require (packages/modules-runtime.js:238:16)
W20180620-21:07:11.544(10)? (STDERR) at index.js (imports/startup/server/index.js:1:50)
W20180620-21:07:11.544(10)? (STDERR) at fileEvaluate (packages/modules-runtime.js:339:7)
W20180620-21:07:11.544(10)? (STDERR) at require (packages/modules-runtime.js:238:16)
W20180620-21:07:11.544(10)? (STDERR) at main.js (server/main.js:1:14)
W20180620-21:07:11.544(10)? (STDERR) at fileEvaluate (packages/modules-runtime.js:339:7)
W20180620-21:07:11.545(10)? (STDERR) at require (packages/modules-runtime.js:238:16)
W20180620-21:07:11.545(10)? (STDERR) at /Users/blakepascoe/Documents/dev/roll_call/.meteor/local/build/programs/server/app/app.js:1725:1
答案 0 :(得分:1)
我尝试了建议的修复方法in the comment by @bp123,该方法是您应该重置Meteor项目,并且也为我进行了修复。
因此,我正在将该评论变为答案:
重置您的项目。
似乎没有必要在将任何数据放入数据库之前添加架构,但是我很困惑为什么这甚至适用于创建架构而不将其附加到任何内容。