我新來的流星,我想做一個使用流星的註冊表格,我卡在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