考虑一下模型:
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) 请随意编辑标题,我不知道如何最好地表达它:).
我有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 …