Meteor.publish('oneStory', function (postId) {
return Stories.find({ _id: new Meteor.Collection.ObjectID(postId) });
});
FlowRouter.route('/:postId', {
subscriptions: function (params, queryParams) {
post = params.postId.toHexString;
this.register('OneStory', Meteor.subscribe('oneStory', post));
},
action(params) {
ReactLayout.render(FullStory, {content: {...params}});
},
});
FullStory = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
var data = {};
// var postId = "ObjectId(\"".concat(this.props.content.postId);
// postId = postId.concat("\")");
data.story = Stories.findOne();
return data;
},
render() {
return (
<div className="col-md-3 col-sm-3 col-xs-3">
<h1>Testing</h1>
</div>
);
}
});
我有一个Mongo系列故事。无论何时,我尝试Stories.findOne({})它返回undefined,我真的很困惑为什么。我已经尝试过在我传入_id:postId的Stories.findOne({}),但这也行不通。我的预感是,实际上没有任何内容发布,但我不确定为什么。真的输了,所以任何帮助都会非常感激!