简体   繁体   中英

How to get if a code exist in parse.com?

I have a problem, I have this structure in parse.com in "VerificationCode" db:

在此处输入图片说明

When someone inserts a code in my app, it automatically adds in the "attachedUser" column the id of the user who is stored locally and I call it "ParseInstallObject.codigo2" and I get the id of the user for example to see it in a textview, etc.

The problem is that I want to check if the user id exists in parse or not; and if it exists do something or if not exist do another thing.

I used a code that I see in the documentation of parse.com but it always shows that the code exists. This is my code:

 ParseQuery<ParseObject> query2 = ParseQuery.getQuery("VerificationCode");
    query2.whereEqualTo("attachedUser", ParseInstallObject.codigo2);
    query2.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> scoreList, ParseException e) {
            if (e == null) {
                comprobar.setText("exist");
                comprobar2.setText("exist");

            } else {
                comprobar.setText("no exist");
                comprobar2.setText("no exist");

            }
        }
    });

How can I see if the user has a valid code or not?

e==null means that the call was successfully completed by the server. It does not imply that the user exists or not.
if(e==null){
if(scoreList == null || scoreList.isEmpty()){
 // The user does not exist.
}else{
// the user exists.
}
}else {
// You have an exception (like HTTPTimeout, etc). Handle it as per requirement.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM