【发布时间】:2011-12-24 13:10:44
【问题描述】:
这里的“self”代表Contact模型。 此查询将查找联系人的所有已完成任务。 任务模型有一个数组类型的字段/键:assigned_contacts。 所以查询是在数组内部搜索。
def assigned_tasks_completed
self.company.tasks.all(:assigned_contacts => self.id.to_s, :completed => true)
end
如何在 Mongoid 中做到这一点?
另一个问题: @contact.set(:a -> a, :b -> b, :c -> c) 在 Mongoid 中的等价物是 update_attributes!
但是在Mongoid中也有设置方法。 set 和 update_attributes 有什么区别!在 Mongoid 中?
【问题讨论】:
标签: ruby mongodb mongoid mongomapper