2015-11-07 212 views
1

我目前正在嘗試編寫Meteor中的登錄程序(是的,我知道默認的登錄程序包)。德恩印刷機的登錄表單上提交一個用戶,一個流星方法調用完成:檢查一個集合是否至少包含一個文檔

Template.Login.events({ 
"submit form": function(event, doc){ 
    event.preventDefault(); 
    var username = doc.find("#login-username").value; 
    var password = doc.find("#login-password").value; 
    Meteor.call("isAdmin",username,password, function(error, result){ 
     console.log("Catchback from Method Call: "); 
     console.log(error); 
     console.log(result); 
    }); 
} 
}); 

而且流星方法,是應該檢查集合包含的條目:

Meteor.methods({ 
    isAdmin: function (username, password){ 
     return !!Admins.find({username: username, password: password}); 
    } 
}); 

問題現在,我只是無法想出一個方法來返回true,當集合包含此用戶的條目時,如果不是,則返回false。它目前只是對所有事情都返回true。

回答

相關問題