【问题标题】:SODA where clause - soda-js in nodeSODA where 子句 - 节点中的 soda-js
【发布时间】:2017-01-28 22:43:37
【问题描述】:

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 的值?

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

谢谢。

【问题讨论】:

    标签: javascript node.js coffeescript soda


    【解决方案1】:

    当然,我只是想通了。

    var soda = require('soda-js');
    
    function getData() {
        consumer.query()
        .withDataset('emea-ai2t')
        .limit(10000)
        .where(soda.expr.gt('inc_datetime', '2017-01-26T13:23:00.000'))
        .getRows()
            .on('success', function(rows) { console.log(rows); })
            .on('error', function(error) { console.error(error); });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多