我正在根据此thinkster.io MEAN stack tutorial创建一个简单的应用。
我的posts.js代码:
var mongoose = require('mongoose');
var PostSchema = new mongoose.Schema({
title: String,
link: String,
upvotes: { type: Number, default: 0 },
comments: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Comment' }]
});
// methods for post
PostSchema.methods.upvote = function (callback) {
this.upvotes += 1;
this.save(callback);
}
mongoose.model('Post', PostSchema);
这是错误:
throw new TypeError('Invalid value for schema path `'+ prefix + key +'`'
^
TypeError: Invalid value for schema path `post.type`at Schema.add
(/Users/macbookpro/flappernews/flapper-news/node_modules/mongoose/lib/schema.js:205:13)
我做过的事情:如果错误与Posts.js之外的内容有关,请使用已完成的存储库编辑/引用其他文件。 回购参考:https://github.com/lepazmino/flapper-news
我该如何解决这个问题?