SODA where子句 - 节点中的soda-js

时间:2017-01-28 22:43:38

标签: javascript node.js coffeescript soda

soda-js package,在src/soda-js.coffee中,我发现了以下内容:

# convenience functions for building where clauses, if so desired
expr =
  and: (clauses...) -> ("(#{clause})" for clause in clauses).join(' and ')
  or:  (clauses...) -> ("(#{clause})" for clause in clauses).join(' or ')

  gt:  (column, literal) -> "#{column} > #{handleLiteral(literal)}"
  gte: (column, literal) -> "#{column} >= #{handleLiteral(literal)}"
  lt:  (column, literal) -> "#{column} < #{handleLiteral(literal)}"
  lte: (column, literal) -> "#{column} <= #{handleLiteral(literal)}"
  eq:  (column, literal) -> "#{column} = #{handleLiteral(literal)}"

我有查询数据的功能:

function getData() {
    consumer.query()
    .withDataset('emea-ai2t')
    .limit(10000)
    .where() //what do I put here to query greater than x in a column? 
    .getRows()
        .on('success', function(rows) { console.log(rows); })
        .on('error', function(error) { console.error(error); });
}

如何使用where便捷函数查询大于x?

仅供参考,我试图查询大于某个值的浮动时间戳。

感谢。

1 个答案:

答案 0 :(得分:1)

当然,我只是想通了。

<table>
  <tr>
    <td>10</td>
    <td>2</td>
    <td></td>
  </tr>
  <tr>
    <td>4</td>
    <td>2</td>
    <td></td>
  </tr>
</table>