49.介绍说明

在本节中,我们来看一些典型的社交游戏应用程序所需的查询。让我们想象,我们正在建立一个游戏叫jungleville

使用以下三个桶:

jungleville - 这个桶包含配置文件数据和游戏的玩家水平等相关数据,经验和各种其他游戏信息。Keys在这个桶以下格式命名:zid-jungle - { user_id }。

jungleville_stats - 这个桶包含系统数据的帧频等游戏加载时间,面对的统计数据。钥匙在这个桶以下格式命名:zid-jungle-stats - { user_id }。

jungleville_inbox - 在jungleville游戏中,每个玩家都有一个收件箱。消息发送到玩家的动作到现有的数组的消息。当消息被一个玩家的消息从消息数组中删除。运行查询看到jungleville的消息是什么样子。

SELECT * FROM jungleville_inbox LIMIT 1

结果:

{
  "results": [
    {
      "jungleville_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"
      }
    }
  ]
}
SELECT * FROM jungleville LIMIT 1

结果:

{
  "results": [
    {
      "jungleville": {
        "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"
      }
    }
  ]
}
SELECT * FROM jungleville_stats LIMIT 1

结果:

{
  "results": [
    {
      "jungleville_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?