小编geo*_*off的帖子

使用yesod持续执行"加入"的正确方法

考虑一下模型:

Player
    name Text
    nick Text
    email Text Maybe
    phone Text Maybe
    note Textarea Maybe
    minutes Int Maybe
    deriving

Table
    name Text
    game Text
    pointsHour Int
    seats Int Maybe
    description Text Maybe
    deriving

GamingSession
    start UTCTime
    end UTCTime Maybe
    player PlayerId
    table TableId
    seat Int Maybe
    deriving
Run Code Online (Sandbox Code Playgroud)

和功能

getGamingSessionsR :: Handler RepHtml
getGamingSessionsR = do
  sessions <- runDB $ selectList [GamingSessionEnd ==. Nothing] [Desc GamingSessionTable]
  defaultLayout $(widgetFile ("opensessions"))
Run Code Online (Sandbox Code Playgroud)

如何获得每个相关会话的所有播放器名称?

players <- runDB $ selectList [FilterOr . map (\(Entity _ …
Run Code Online (Sandbox Code Playgroud)

haskell persistent yesod

8
推荐指数
2
解决办法
1296
查看次数

如何使用jq从子数组创建具有任意键的对象?

请随意编辑标题,我不知道如何最好地表达它:).

我有JSON,例如,看起来像这样:

{
  "things": [
     {
        "name": "foo",
        "params": [
           {
             "type": "t1",
              "key": "key1",
              "value": "val1"
           },
           {
              "type": "t1",
              "key": "category",
              "value": "thefoocategory"
           }
        ]
      },
      {
        "name": "bar",
        "params": [
           {
             "type": "t1",
             "key": "key1",
             "value": "val1"
           },
           {
             "type": "t1",
             "key": "category",
             "value": "thebarcategory"
           }
        ]
     }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我想要实现的是输出看起来像

[
  {
    name: "foo",
    category: "thefoocategory"
  },
  {
    name: "bar",
    category: "thebarcategory"
  }
]
Run Code Online (Sandbox Code Playgroud)

我能够很容易地提取名称 jq ' .things | .[] | .name'

我也可以提取类别 jq ' .things …

json jq

4
推荐指数
1
解决办法
5313
查看次数

标签 统计

haskell ×1

jq ×1

json ×1

persistent ×1

yesod ×1