2015-10-01 212 views
0

我正在寻找一种查询我的应用的用户数据库用户名的好方法。这样人们无法使用与其他人相同的用户名注册。检查用户名是否存在| Parse.com

我正在使用用户名,密码和电子邮件来恢复密码。所以我想基本检查用户名。 我明白这可以用ParseQuery来实现吗? 我想要一个例子,如果任何人都可以提供?

+1

检查此问题http://stackoverflow.com/questions/17222158/parse-com-get-value-with-query – Sony

回答

1

您可以使用ParseQuery像这样查询数据库中的所有用户名。

ParseQuery<ParseObject> query = ParseQuery.getQuery("User"); 
    query.findInBackground(new FindCallback<ParseObject>() { 
     public void done(List<ParseObject> objects, ParseException e) { 
      if (e == null) { 
       // objects is a list of all the User you have. Just get all the usernames, 
       //and check if there's already one equal to the one you want to insert. 
      } else { 
       //error handling 
      } 
     } 
    }