【发布时间】:2016-07-08 09:39:57
【问题描述】:
我是流星的新手,我想用流星制作注册表,我卡在findOne和subscribe/publish。
这是我的 `collection.js common :
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将返回如果email/identity/phone已经存在于集合中:
Identity in Customer
Email in User_Customer
Phone in User_Customer
问题是进程不能继续进入第二个订阅,在我用我的 chrome 做断点之后,cust 有 undefined 值。
请帮助我,如何解决这个功能?
谢谢
【问题讨论】:
标签: javascript meteor