如何在Rails查询中查找nil的相反值

3

很高兴地使用MongoidActiveRecord,如下所示:

Task.where(project_id: params[:project_id], archived_at: nil)
# find me the tasks for project_id that haven't been archived

但是如何简明地表示相反的意思呢?
# find me the tasks for project_id that have been archived
# i.e. where archived_at is not nil

无法理解或找到第一行代码的逆运算。

我认为这应该很简单 :)

1个回答

2
我认为你想要使用这个:

我认为您想使用这个:

:archived_at.ne => nil 

请看这里:MongoId-Matchers-NE

这是一个与MongoDB相关的IT技术链接。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接