2014-05-05 62 views
1

使用parse.com和JavaScript SDK,我想創建一個查詢,檢查用戶是否已經存在。無法搜索用戶使用parse.com查詢和JavaScript SDK

這裏有一個示例代碼,我已經採用並轉換爲下面的代碼塊。我收到一個Uncaught ReferenceError: username is not defined錯誤,我不明白爲什麼?

https://www.parse.com/docs/js_guide#users

var friendFinder = Parse.Object.extend("_User"); 
var query = new Parse.Query(Parse.User); 
query.equalTo(username, "d"); // find users that match 
query.find({ 
    success: function (friend) { 
     if (friendName.length) { 
      console.log("Success") 
     } 
    }, 
    error: function (error) { 
     //Show if no user was found to match 


    } 
}); 

回答

1

你忘了引號的 「用戶名」 欄:

var friendFinder = Parse.Object.extend("_User"); 
var query = new Parse.Query(Parse.User); 
query.equalTo("username", "d"); // find users that match 
query.find({ 
    success: function (friend) { 
     if (friendName.length) { 
      console.log("Success") 
     } 
    }, 
    error: function (error) { 
     //Show if no user was found to match 


    } 
});