【问题标题】:how to reference another attribute mongoid selection :created_at.gte => :some_other_timestamp如何引用另一个属性 mongoid 选择:created_at.gte => :some_other_timestamp
【发布时间】:2014-08-18 23:29:30
【问题描述】:

在 Rails 3 应用上使用 Mongoid

我想像这样运行比较查询

Model.where(:created_at.gte => (:some_other_timestamp))

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 mongoid mongoid3


    【解决方案1】:

    尝试在查询中使用 JavaScript 表达式 ($where),如下所示:

    Model.where('this.created_at >= this.some_other_timestamp')
    

    【讨论】:

    • 这段时间跨 1100 万个文档是否有效?
    猜你喜欢
    • 1970-01-01
    • 2017-01-29
    • 2012-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    • 2013-02-11
    • 2017-12-16
    相关资源
    最近更新 更多