检索Parse.com从类数据 [英] Retrieve data from a class in Parse.com

查看:196
本文介绍了检索Parse.com从类数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Parse.com一类,如XYZ,它有列电子邮件,密码,电话,年龄。我有电子邮件和密码组合,我要检查是否有类这样的组合?我该怎么做呢?

I have a class in Parse.com, as XYZ, and it has columns email, password, phone, age. I have email and password combination and I want to check whether there is such a combination in the class? How do I do this?

我有一个类捐赠,而且我得到了一个电子邮件(e)和密码(PW)。下面那张code:

I have a class Donate, and I have been given an email(e) and password(pw). Here goes the code:

`ParseQuery<ParseObject> query = ParseQuery.getQuery("donate");
            query.whereEqualTo("email", e);
            query.whereEqualTo("password", pw);
            query.findInBackground(new FindCallback<ParseObject>() {
                @Override
                public void done(List<ParseObject> list, ParseException e) {
                    if (e == null) {
                        Toast.makeText(getApplicationContext(), "Success!!!", Toast.LENGTH_LONG).show();
                    } else {
                        Toast.makeText(getApplicationContext(), "Something went wrong!!!", Toast.LENGTH_LONG).show();
                    }
                }
            });                     `            

这总是显示成功不论串电子商务和PW。

And this always shows 'success' irrespective of the strings e, and pw.

推荐答案

ParseQuery 返回 ParseException的只是,如果有技术问题呼叫服务器。
否则,即使您的查询没有找到你看什么的
它会返回一个空列表E变种无效即可。
所以你需要做的是:

ParseQuery return ParseException just if there was technical issue calling the server. else, even though your query doesn't find exactly what you looked for, it will return an empty list and the 'e' var will be null. so what you need to do is :

    ParseQuery<ParseObject> query = ParseQuery.getQuery("donate");
    query.whereEqualTo("email", e);
    query.whereEqualTo("password", pw);
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> list, ParseException e) {
            if (e == null) {
                if (list.isEmpty() == false) {   // add this
                    Toast.makeText(getApplicationContext(), "Success!!!", Toast.LENGTH_LONG).show(); 
                }else{
                    Toast.makeText(getApplicationContext(), "Worng password!!!", Toast.LENGTH_LONG).show(); // add this

                }

            } else {
                Toast.makeText(getApplicationContext(), "Something went wrong!!!", Toast.LENGTH_LONG).show();
            }
        }
    });

这篇关于检索Parse.com从类数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆