如何查询用户指针<&_user GT;使用Parse.com与Android领域 [英] How to query a user Pointer<_user> field using Parse.com with Android

查看:111
本文介绍了如何查询用户指针<&_user GT;使用Parse.com与Android领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的与此查询挣扎,所有我想要做的就是贯穿我的套路表中选择属于某个用户例程的查询。运行正常查询将需要一些query.whereEqualTo(routineIcon,1)将调出的第一和第三行。不过,棘手位查询用户(点< _user>)领域,这是从用户类用户(OBJECTID)的引用。起初我试图query.whereEqualTo(用户,RE1bvmzyPk),但这个出来的空白让我看着查询指针,我已经特里为d的几件事情,但不能让它开始工作。任何人有什么秘诀?

Really struggling with this query, all I want to do is run a query through my Routines table selecting Routines that belong to a certain user. Running a normal query would require something query.whereEqualTo("routineIcon", "1") would bring up the the first and third row. However, the tricky bit is querying the user (Point<_user>) field, this is a reference to a user (objectId) from the User class. Initially I tried query.whereEqualTo("user", "RE1bvmzyPk"), but this came out blank so I looked into querying Pointers, I've trie d a few things but can't get it to work. Anyone got any tips?

private void retrieveRoutines() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Routine");
    query.whereEqualTo("user", "RE1bvmzyPk");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> routines, ParseException e) {
            if (e==null){
                mRoutines = routines;
                String[] routineNames = new String[mRoutines.size()];
                int i = 0;
                for (ParseObject routine : mRoutines) {
                    routineNames[i] = routine.getString("routineName");
                    Log.d("OK", routineNames[i]);
                    i++;
                }


            }

            else {
                //error
            }
        }
    });
}

常规类的格式为:

The Routine Class is in the format:

对象ID(字符串)| routineIcon(串)| routinesName(串)|用户(指针&LT; _user>

推荐答案

您可以通过使用用户的OBJECTID创建用户指针

You can create the user pointer by using the objectid of the user

ParseUser user=new ParseUser();
user.setObjectId("RE1bvmzyPk");

ParseQuery<ParseObject> query = ParseQuery.getQuery("Routine");
query.whereEqualTo("user", user);
query.findInBackground(new FindCallback<ParseObject>() {
    @Override
    public void done(List<ParseObject> routines, ParseException e) {
        if (e==null){



        }

        else {
            //error
        }
    }
});

这篇关于如何查询用户指针&LT;&_user GT;使用Parse.com与Android领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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