如何在FQL查询中使用用户表的设备字段? [英] How to use devices field of the user table in FQL query?

查看:67
本文介绍了如何在FQL查询中使用用户表的设备字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望FQL查询的结果只能在设备列表中返回具有iOS设备的用户的朋友。以下查询:

  SELECT uid,first_name,devices 
FROM user
WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY profile_update_time DESC
LIMIT 0,100

返回一个这样的列表:

  {
data:[
{
uid:12345678,
first_name:John,
devices:[
{
os:iOS,
硬件:iPhone
}
]
},
{
uid:1234345678,
first_name:Pete ,
}
}

现在我只想检索有至少一个设备,其中os是iOS。我试过包括

  devices.os =iOS

在查询中,但这返回一个错误。



这可能通过FQL查询?或者应该解决客户端?

解决方案

只是发现它 IS 可能!您可以使用 IN 运算符与设备列。没有必要限制到os或硬件。



示例:所有有iPhone的朋友: 试用

  SELECT uid,name,devices FROM user 
WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())
ANDiPhoneIN设备
ORDER BY profile_update_time DESC
LIMIT 0,100

示例:所有拥有iOS设备的朋友(例如iPhone或iPad): 试用

  select uid,name,devices FROM user 
WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())
ANDiOSIN devices
ORDER BY profile_update_time DESC
提示:如果要使用此查询构建自定义的朋友选择器以发送,请单击是,然后单击确定。邀请尚未安装iOS应用程序但拥有iOS设备的Facebook朋友,您要将以下内容添加到 WHERE 子句中:

  AND is_app_user = 0 


I would like the result of a FQL query to only return friends of a user which have a iOS device in their devices list. The following query:

SELECT uid, first_name, devices 
FROM user 
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY profile_update_time DESC 
LIMIT 0, 100

returns a list like this:

{
  "data": [
    {
      "uid": 12345678, 
      "first_name": "John", 
      "devices": [
        {
          "os": "iOS", 
          "hardware": "iPhone"
        }
      ]
    },
    {
      "uid": 1234345678, 
      "first_name": "Pete", 
    }
}

Now I would like to only retrieve users who have at least one device where the os is "iOS". I have tried including

devices.os = "iOS"

in the query but this returned an error.

Is this possible through the FQL query? Or should this be solved client side?

解决方案

Just found out that it IS possible! You can use the IN operator just with the devices column. There is no need to restrict to os or hardware.

Example: all friends that have an iPhone: try out

SELECT uid, name, devices FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
  AND "iPhone" IN devices
ORDER BY profile_update_time DESC 
LIMIT 0, 100

Example: all friends that have an iOS device (e.g. iPhone or iPad): try out

SELECT uid, name, devices FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
  AND "iOS" IN devices
ORDER BY profile_update_time DESC 
LIMIT 0, 100

Hint: If you want to use this Query to build a custom Friend Picker to send invites to Facebook friends that not yet have installed your iOS app but have an iOS device, you want to include the following into your WHERE clause:

AND is_app_user = 0

这篇关于如何在FQL查询中使用用户表的设备字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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