我正在阅读Discover Meteor一书,在实施了“错误”一章之后,一个拼写错误引起了错误,现在应用程序循环播放,下面是例外情况。
我的问题是,如何解决或重置(我已经尝试'流星重置',但异常循环仍然存在)
W20140711-10:21:00.387(2)? (STDERR)
W20140711-10:21:00.388(2)? (STDERR) /Users/mwho/.meteor/tools/858c88b520/lib/node_modules/fibers/future.js:173
W20140711-10:21:00.390(2)? (STDERR) throw(ex);
W20140711-10:21:00.391(2)? (STDERR) ^
W20140711-10:21:00.479(2)? (STDERR) Error: allow: Invalid key: remote
W20140711-10:21:00.480(2)? (STDERR) at packages/mongo-livedata/collection.js:575
W20140711-10:21:00.492(2)? (STDERR) at Array.forEach (native)
W20140711-10:21:00.493(2)? (STDERR) at Function._.each._.forEach (packages/underscore/underscore.js:105)
W20140711-10:21:00.494(2)? (STDERR) at addValidator (packages/mongo-livedata/collection.js:573)
W20140711-10:21:00.496(2)? (STDERR) at Meteor.Collection.allow (packages/mongo-livedata/collection.js:613)
W20140711-10:21:00.496(2)? (STDERR) at app/collections/posts.js:3:7
W20140711-10:21:00.497(2)? (STDERR) at app/collections/posts.js:52:3
W20140711-10:21:00.498(2)? (STDERR) at /Users/mwho/microsope/.meteor/local/build/programs/server/boot.js:155:10
W20140711-10:21:00.500(2)? (STDERR) at Array.forEach (native)
W20140711-10:21:00.500(2)? (STDERR) at Function._.each._.forEach (/Users/mwho/.meteor/tools/858c88b520/lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8
Posts.js
Posts = new Meteor.Collection('posts');
Posts.allow({
update: ownsDocument,
remote: ownsDocument
});
Posts.deny({
update: function( userId, post, fieldNames ) {
// may only edit the following two fields:
return (_.without(fieldNames, 'url', 'title').length > 0);
}
});
Meteor.methods({
post: function(postAttributes) {
var user = Meteor.user(),
postWithSameLink = Posts.findOne({
url: postAttributes.url
});
// ensure the user is logged in
if (!user) throw new Meteor.Error(401, "You need to login to post new stories");
// ensure the post has a title
if (!postAttributes.title) throw new Meteor.Error(422, 'Please fill in a headline');
// check that there are no previous posts with the same link
if (postAttributes.url && postWithSameLink) {
throw new Meteor.Error(302,
'This link has already been posted', postWithSameLink._id);
}
// pick out the whitelisted keys
var post = _.extend(_.pick(postAttributes, 'url', 'title', 'message'), {
title: postAttributes.title + (this.isSimulation ? '(client)' : '(server)'),
userId: user._id,
author: user.username,
submitted: new Date().getTime()
});
//
// wait 5 seconds
if ( ! this.isSimulation ) {
var Future = Npm.require('fibers/future');
var future = new Future();
Meteor.setTimeout( function() {
future.return();
}, 5*1000);
future.wait();
}
var postId = Posts.insert(post);
return postId;
}
});
答案 0 :(得分:1)
您的代码中存在拼写错误。
Posts.allow({
update: ownsDocument,
remote: ownsDocument
});
应更改为
Posts.allow({
update: ownsDocument,
remove: ownsDocument
});