简单架构无法正常工作

时间:2016-02-12 12:46:41

标签: javascript meteor

我在meteor.js应用程序中不断收到以下错误我不知道是什么错误一直跟着教程完成:

这是我的代码:

Recepies = new Mongo.collection('recepies');

RecepieSchema = new SimpleSchema({
 name: {
    type: string,
    label: "Name"
  },
desc: {
    type: string,
    label: "Description"
   },
author: {
    type: string,
    label: "Author",
    autoValue: function () {
        return this.userId
    }
  },
createdAt: {
    type: date,
    label: "created At",
    autoValue: function () {
        return new Date()
     }
   }
  });
  Recepies.attachSchema( RecepieSchema);

终端错误:

  

启动MongoDB   W20160212-14:38:03.572(2)? (STDERR)
  W20160212-14:38:03.575(2)? (STDERR)/Users/sypher47/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server- LIB / node_modules /纤维/ future.js:245   W20160212-14:38:03.575(2)? (STDERR)throw(ex);   W20160212-14:38:03.575(2)? (STDERR)^   W20160212-14:38:03.575(2)? (STDERR)TypeError:undefined不是函数   W20160212-14:38:03.575(2)? (STDERR)在馆藏/ Recepies.js:1:12   W20160212-14:38:03.576(2)? (STDERR)/Users/sypher47/recipes/.meteor/local/build/programs/server/app/collections/Recepies.js:39:4   W20160212-14:38:03.576(2)? (STDERR)/Users/sypher47/recipes/.meteor/local/build/programs/server/boot.js:242:10   W20160212-14:38:03.576(2)? (STDERR)在Array.forEach(本机)   W20160212-14:38:03.576(2)? (STDERR)在函数。 .each。 .forEach(/Users/sypher47/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+ web.cordova / MT-os.osx.x86_64 / dev_bundle /服务器-LIB / node_modules /下划线/ underscore.js:79:11)   W20160212-14:38:03.576(2)? (STDERR)/Users/sypher47/recipes/.meteor/local/build/programs/server/boot.js:137:5   =>退出代码:8

1 个答案:

答案 0 :(得分:3)

您需要使用大写的“C”定义集合:

Recepies = new Mongo.Collection('recepies');

您的内容会显示Mongo.collection,因此您会收到undefined is not a function错误。