Firestore:不等式过滤器属性和第一排序顺序必须相同。不同字段中的条件和顺序失败。这是预期的吗?

Shi*_*il 5 javascript google-cloud-firestore

我有一个这样的文档集合:

{
   uid: <UNIQUE_USER_ID>,
   lastLoggedIn: <TIMESTAMP_IN_NUMBER>,
   ...
}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下方式获取数据时:

Server.db
    .collection(firebasePaths.funfuse_verified_users)
    .where('uid', 'not-in', notToIncludeAccounts)
    .orderBy('lastLoggedIn', 'desc')
    .startAt(startAt)
    .limit(limit)
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:

Error: 3 INVALID_ARGUMENT: inequality filter property and first sort order must be the same: uid 
and lastLoggedIn
Run Code Online (Sandbox Code Playgroud)

这是 firebase 的已知限制还是我做错了什么?我想查询不在数组中的所有用户using not-in,然后根据lastLoggedIn时间戳活动对这些结果进行排序。

Fra*_*len 16

正如错误消息所示,为了能够使用,not-in您必须首先在同一字段上订购:

Server.db
    .collection(firebasePaths.funfuse_verified_users)
    .orderBy('uid')
    .where('uid', 'not-in', notToIncludeAccounts)
    .orderBy('lastLoggedIn', 'desc')
    .startAt(startAt)
    .limit(limit)
Run Code Online (Sandbox Code Playgroud)

这也意味着结果将首先在 上排序uid,然后才在 上排序(因此,如果有多个结果具有相同的uid值)lastLoggedIn。如果您在其他订单中需要它们,则必须在应用程序代码中重新调用它们。