SimpleSchema 不是构造函数

SimpleSchema is not a constructor

我的应用经常因为这个错误而崩溃。 TypeError: SimpleSchema is not a constructor at attendances.js (imports/api/attendances/attendances.js:44:27)。我用谷歌搜索了一下,Whosebug 解决方案不起作用。我是 运行 simpl-schema and 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

我尝试了建议的修复 ,您应该重置 Meteor 项目,我也修复了它。

所以我要把评论变成答案:

重置您的项目。

在将任何数据放入数据库之前需要添加模式似乎并非不可能,但我很困惑为什么这甚至适用于创建模式而不将其附加到任何东西。