4

When I try to make the query:

query PapersFromAPoll
{
    description: "retrieve all the papers from a poll"
    statement:
         SELECT org.acme.democracity.Paper 
          WHERE(poll.pollId == _$id)
}

I am not able to get any rows, here is the fragment where I make this query:

return query('PapersFromAPoll',{id : count.poll.pollId})

It is strange because when I erase the WHERE statement and I make a simple query without any parameters it works perfectly.

Paper and Poll in model.cto file:

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
}

1 Answers1

5
query PapersFromAPoll
{
  description: "retrieve all the papers from a poll"
  statement:
    SELECT org.acme.democracity.Paper 
      WHERE(poll == _$pollId)
}

So you can filter by the Poll asset by giving a reference to that Poll asset. When you try to query with the pollId it will have to be a reference to the resource resource:org.acme.democracity.Poll#{insert_id}

TheOkayCoder
  • 127
  • 7