SimpleSchema不是构造函数 [英] SimpleSchema is not a constructor

查看:102
本文介绍了SimpleSchema不是构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序经常因该错误而崩溃. TypeError: SimpleSchema is not a constructor at attendances.js (imports/api/attendances/attendances.js:44:27).我已经用谷歌搜索了,而StackOverflow解决方案不起作用.我正在运行 simpl-schema

My app constantly crashes with this error. TypeError: SimpleSchema is not a constructor at attendances.js (imports/api/attendances/attendances.js:44:27). I've googled it and the StackOverflow solution doesn't work. I'm running simpl-schema and Collection2 Can anyone tell me whats wrong here?

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;

这是我终端中的完整错误消息.

This is the full error message in my terminal.

路径: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

推荐答案

我尝试了建议的修复方法

I tried the suggested fix in the comment by @bp123 that you should reset the Meteor project, and that fixed it for me too.

因此,我正在将该评论变为答案:

So I'm turning that comment into an answer:

重置您的项目.

似乎没有必要在将任何数据放入数据库之前添加模式,但是我很困惑为什么即使在不将其附加到任何内容的情况下创建模式也要应用这种模式.

It does not seem impossible that a schema need to be added before any data is put in the database, but I'm very confused why this applies even for creating a Schema without attaching it to anything.

这篇关于SimpleSchema不是构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆