我正在查询firestore:
this.todosCollection = this.afs.collection('todos', ref => ref.where('owner', '==', this.userId). orderBy('due', 'asc'));
todo项目按照我的要求按升序排序,问题是没有到期日期(null)的待办事项首先出现。我希望他们能够到最后。这可能在orderBy或其他技术中吗?
这就是空值排序的工作方式。 documentation清楚地说明了这一点,它在查询本身中无法改变。
如果要更改排序,则必须手动对客户端上的文档进行重新排序,以支持您的首选排序。或者,您将必须进行两个查询,一个包含null,另一个不包含,然后自己合并结果。