简体   繁体   English

如何获取parse.com中是否存在代码?

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

I have a problem, I have this structure in parse.com in "VerificationCode" db: 我有一个问题,我在parse.com中的“ VerificationCode”数据库中具有以下结构:

在此处输入图片说明

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. 当有人在我的应用程序中插入代码时,它会自动在“ attachedUser”列中添加本地存储的用户ID,我将其称为“ ParseInstallObject.codigo2”,例如,我获得该用户的ID以在其中查看文本视图等

The problem is that I want to check if the user id exists in parse or not; 问题是我想检查用户ID是否存在于解析中。 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. 我使用了在parse.com文档中看到的代码,但它始终表明该代码存在。 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.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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