当我尝试进行查询时:
query PapersFromAPoll
{
description: "retrieve all the papers from a poll"
statement:
SELECT org.acme.democracity.Paper
WHERE(poll.pollId == _$id)
}
我无法获取任何行,这是我进行此查询的片段:
return query('PapersFromAPoll',{id : count.poll.pollId})
这很奇怪,因为当我擦除WHERE语句并且我在没有任何参数的情况下进行简单查询时,它完美地运行。
在model.cto文件中进行纸张和投票:
asset Paper identified by paperId {
o String paperId
o String[] fields
--> Poll poll //Paper related with a poll
}
asset Poll identified by pollId {
o String pollId
o Ask[] asks
}
答案 0 :(得分:5)
query PapersFromAPoll
{
description: "retrieve all the papers from a poll"
statement:
SELECT org.acme.democracity.Paper
WHERE(poll == _$pollId)
}
因此,您可以通过提供对该Poll
资产的引用来按Poll
资产进行过滤。当您尝试使用pollId
进行查询时,它必须是对资源的引用resource:org.acme.democracity.Poll#{insert_id}