我新来的流星,我想做一个使用流星的注册表格,我卡在findOne
和subscribe/publish
。 这是我的`collection.js常见:流星订阅undefined
User_Customer = new Meteor.Collection("USER_CUSTOMER");
Customer = new Meteor.Collection("CUSTOMER");
这是我publish.js
/server
:
Meteor.publish("CUSTOMER", function() {
return Customer.find();
});
Meteor.publish("USER_CUSTOMER", function() {
return User_Customer.find();
});
,这是我的功能来订阅和findOne /client
:
function isAvailableForUserRegister(email,identiy,phone){
Meteor.subscribe("CUSTOMER", function(){
var cust = null;
cust = Customer.findOne({Identity: identiy});
if(cust != null){
Meteor.subscribe("USER_CUSTOMER", function(){
var uc1 = null;
uc1 = User_Customer.findOne({Email: email});
if(uc1 != null){
var uc2 = null;
uc2 = User_Customer.findOne({Phone: phone});
if(uc2 != null)
return true
else
return false;
}else return false;
});
}else return false;
});
}
此功能isAvailableForUserRegister
将返回,如果电子邮件/身份证/电话已存在集合中:
Identity in Customer
Email in User_Customer
Phone in User_Customer
和问题的过程无法继续进入第二认购后,我做的断点与我的铬,cust
有undefined
值。 请帮帮我,该如何解决这个功能?
感谢
感谢答案,我试试您的解决方案,但它仍然未定义 – yozawiratama