50.组装和加载用户配置信息

在游戏客户端应用程序需要加载数据从所有的桶。这可以通过运行一个N1QL查询。下边的查询组装三个通,并且用户KEYS为“zid-jungle-0001”。

如果你注意到game-data属性有一个连字符的名称,查询中使用` 扩起来。

SELECT * 
FROM jungleville AS `game-data` 
JOIN  jungleville_stats AS stats
      ON KEYS "zid-jungle-stats-0001" 
NEST  jungleville_inbox AS inbox 
      ON KEYS "zid-jungle-inbox-0001" 
WHERE `game-data`.uuid="zid-jungle-0001"

结果:

{
  "results": [
    {
      "game-data": {
        "friends": [
          "zid-jungle-0002",
          "zid-jungle-0003"
        ],
        "gameworld": {
          "farm-length": 32,
          "farm-width": 64,
          "piggies": [
            "nero",
            "hero",
            "coma"
          ],
          "position": [
            23,
            45,
            12
          ]
        },
        "lastLogin": "22nd December 2013",
        "level": 4,
        "loggedIn": false,
        "name": "Don Pinto",
        "payer": false,
        "score": 663,
        "type": "player",
        "uuid": "zid-jungle-0001"
      },
      "inbox": [
        {
          "messages": [
            {
              "content": "more work",
              "message": "more help for you ",
              "type": "gift",
              "user": "zid-jungle-0002"
            },
            {
              "content": null,
              "message": "1.2.3.Go",
              "type": "help-needed",
              "user": "zid-jungle-0002"
            },
            {
              "content": "meat-cleaver",
              "message": "hungry like the wolf",
              "type": "help-needed",
              "user": "zid-jungle-0003"
            }
          ],
          "uuid": "zid-jungle-0001"
        }
      ],
      "stats": {
        "avg_session_length": 1145,
        "country": "India",
        "fps": 34,
        "lastLogin": "22nd December 2013",
        "loadtime": 23,
        "loggedIn": false,
        "pvp-hist": [
          {
            "result": "lost",
            "uuid": "zid-jungle-0003"
          },
          {
            "result": "lost",
            "uuid": "zid-jungle-0002"
          }
        ],
        "requests": 6,
        "session_hist": [
          122,
          3334,
          1223,
          1123,
          145
        ],
        "type": "player",
        "uuid": "zid-jungle-0001"
      }
    }
  ]
}

Last updated

Was this helpful?