0

我有一个 ReQL 查询...

r.db('development').table('responses').filter({
  survey_id: 9
}).concatMap(r.row.getField('numerical_answers')).filter({
  type: 'CustomerEffortAnswer'
}).sum('number')

...我想在NoBrainer中工作,因为我似乎无法让它在 Ruby on Rails 上工作。当我尝试像这样在 Rails 中运行 ReQL 时......

NoBrainer.run do |r|
  return_count = r.db('development').table('responses').filter({ survey_id: id }).concatMap(r.row.getField('numerical_answers')).filter({type: 'CustomerEffortAnswer'}).sum('number')
end

...我得到错误:

Sorry, r.row is not available in the ruby driver. Use blocks instead.
4

1 回答 1

0

需要将代码转换为 Ruby 语言:

return_count = NoBrainer.run do |r|
  r.db('development').table('responses')
  .filter({:survey_id => 9})
  .concat_map { |doc| doc[:numerical_answers] }
  .filter({:type => 'CustomerEffortAnswer'})
  .sum('number')
end
于 2021-04-02T02:19:46.163 回答