【发布时间】:2014-04-24 15:02:52
【问题描述】:
我有一个使用“角色”包的简单 Meteor/MongoDB 项目,我将数据从数据库选择到客户端。角色包似乎工作正常,浏览器根据登录者显示正确的数据,就像它应该做的那样。然后,当在我的应用程序目录内的终端中运行“流星删除自动发布”时,我会得到“自动发布删除”,就像它应该的那样。我仍然可以像以前一样从服务器检索数据(!?)
我有来自 client/client.js 的所有数据库调用。
server/server.js 什么都不做(我确实有发布/订阅代码,但现在取消注释),主目录中的公共 js 文件也是如此。
这怎么可能?我是否可能以某种方式从 minimongo 检索数据?即使我认为在这种情况下不重要,我也删除了不安全(?)提前谢谢。
编辑:这是代码:
client.js:
//when uncomment the subscribe's you should not get access to the server/db, but 'data' that holds all the inlogg info still shows. The 'movies' on the other hand doesn't, just like it shouldn't.
//Meteor.subscribe('data');
//Meteor.subscribe('movies');
/*############# Get User Data ###############*/
Template.userLoggedIn.id = function () {
return Meteor.userId();
};
Template.userLoggedIn.email = function () {
var email = Meteor.users.findOne({_id: Meteor.userId()});
return email.emails[0].address;
};
Template.userLoggedIn.profile = function () {
var profile = Meteor.users.findOne({_id: Meteor.userId()});
return profile.profile.name;
};
Template.userLoggedIn.role = function () {
var role = Meteor.users.findOne({_id: Meteor.userId()});
return role.roles[0];
};
/*############# ###############*/
Template.movies.movies = function() {
var movies = Movies.find().fetch();
return movies;
}
server.js:
Meteor.publish('data', function () {
return Meteor.users.find();
});
Meteor.publish('movies', function() {
return Movies.find();
});
【问题讨论】:
-
删除
autopublish将重新加载您的应用程序,然后清除您的 minimongo 数据。不看代码真的很难回答这个问题。meteor list --using显示什么?您可能还需要仔细检查这些发布功能是否实际上已被注释掉。 -
感谢您的回答。这是终端列出的内容:standard-app-packages accounts-password roles accounts-ui