Parse.com质疑指针值 [英] Parse.com Query on Pointer value

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

问题描述

我使用 Parse.com 我的Andr​​oid应用程序的数据库。

总之,我询问有指向类B.如果我查询A类,包括B类的字段A级反正有我可以通过一个字段B类具有查询过滤器和/或排序<? / p>

我更熟悉SQL风格DB作为可以从我的描述变得明显。在解析我有邀请去参加一个游戏gameInvitees与一些元数据的人,例如,当他们被邀请和他们的RSVP状态的表。然后用游戏gameInstances一个单独的表。在gameInvitees包含一个指向游戏,他们被邀请和被邀请用户解析

我的问题是我想查询gameInvitees表,以便我能找到应邀根据游戏时间的游戏,这是在gameInstance表当前用户。

我目前的code看起来是这样的:

 日历CAL = Calendar.getInstance();
    cal.setTime(新的Date());
    cal.add(Calendar.HOUR,-1);
    最后日期oneHourBack = cal.getTime();
    //获得游戏当前用户被邀请
    ParseQuery&LT; GamePhaseInvitees&GT; inviteeQuery = ParseQuery.getQuery(gameInvitees);
    inviteeQuery.whereEqualTo(inviteeAccount,ParseUser.getCurrentUser()); //当前用户邀请
    inviteeQuery.include(GameInstance);
    // inviteeQuery.whereGreaterThanOrEqualTo(GameInstance.GameTime,oneHourBack); //游戏是一个小时回来(但是,这不起作用)
    inviteeQuery.findInBackground(新FindCallback&LT; GamePhaseInvitees&GT;(){
        公共无效完成(列表&LT; GamePhaseInvitees&GT; gamesInvitedToList,ParseException的E){
            如果(E == NULL){            }其他{
            }        }
    });

这code简化一点来解释这个问题。基本上,我需要弄清楚的东西我可以与注释掉行做在由指针连接的字段查询。那可能吗?是否有任何解决方法清洁的解决方案是什么?


解决方案

下面是一个可能的解决方案:

从表的类型创建的parseObject:的parseObject时间=新的parseObject(日期);
然后,从结果中获得的parseObject: =时间result.getParseObject(的pointer_field);

现在你可以从时间拉任何领域,它有就像你会做正常,例如: time.getString(some_field )

您可能还需要包括: query.include(的pointer_field)

I'm using Parse.com for my android apps database.

In short I'm querying class A that has a field pointing to class B. If I query class A and include class B is there anyway I can have the query filter and/or sort by a field in class B?

I'm more familiar with sql style db as may become obvious from my description. In parse I have a table for the people invited to a game "gameInvitees" with some metadata such as when they were invited and their rsvp status. Then a separate table with the games "gameInstances". The "gameInvitees" include a pointer to the game they are invited to and the parse user that is invited.

My issue is I'm trying to query the "gameInvitees" table so that I can find current users invited to a game based on the game time, which is in the "gameInstance" table.

My current code looks something like this:

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.HOUR, -1);
    final Date oneHourBack = cal.getTime();


    // get games that the current user is invited to
    ParseQuery<GamePhaseInvitees> inviteeQuery = ParseQuery.getQuery("gameInvitees");
    inviteeQuery.whereEqualTo("inviteeAccount", ParseUser.getCurrentUser());  // current user is invited
    inviteeQuery.include("GameInstance");
    //    inviteeQuery.whereGreaterThanOrEqualTo("GameInstance.GameTime", oneHourBack);  // game is one hour back (but, this doesn't work)


    inviteeQuery.findInBackground(new FindCallback<GamePhaseInvitees>() {
        public void done(List<GamePhaseInvitees> gamesInvitedToList, ParseException e) {
            if (e == null) {

            } else {
            }

        }
    });

That code is simplified a bit to explain the problem. Basically I need to figure out something I can do with that commented out line to query on a field that is connected by a pointer. Is that possible? Are there any clean workaround solutions for that?

解决方案

Here is a possible solution:

Create a ParseObject from the type of your table: ParseObject time = new ParseObject("Date"); Then get the ParseObject from the result: time = result.getParseObject(pointer_field);

Now you can pull from time any field that it has just as you would do it normally, for example: time.getString("some_field").

You may also need to include: query.include("pointer_field").

这篇关于Parse.com质疑指针值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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