1
好的,我想查询MongoID以再次检查一个参数。想象一下,我有start_date
和end_date
作为我的模型的属性。我想要这样查询Mongoid:如何在Mongoid中运行MongoDB本地查询
Model.where(start_date > end_date)
那么我该怎么做呢?如果我要使用MongoDB控制台,我会做类似(未经测试):
db.collection.find({$where: "this.end_date > this.start_date"}).count()
任何想法?
你试过'Model.collection.find( '$其中'=> 'this.end_date> this.start_date' )'或在Mongoid 3中作为'Model.where('this.end_date> this.start_date')'? – chridam
不,我没有,一旦我现在完成,它的工作。你想添加一个答案吗? – WagnerMatosUK