Android 无效的查询。您不能使用';数组包含';带有';不在';过滤器
我有一个名为channels的集合 用户被添加到userid数组中,记录也保存到名为serverId的字段中 我只需要一个新创建或更新的行列表来更新到我的本地房间数据库 每次发生任何更改时,我都会更新快照时间字段 之前我使用了以下代码,其中lastTime是本地房间db的最大值(快照时间) 它返回更新的字段,但不返回新记录 因此,我尝试此查询仅获取新行: 此处通道是本地数据库中所有通道SID的列表 现在遇到的错误是: 无效查询。不能将“array\u contains”筛选器与“not\u in”筛选器一起使用Android 无效的查询。您不能使用';数组包含';带有';不在';过滤器,android,firebase,kotlin,google-cloud-firestore,Android,Firebase,Kotlin,Google Cloud Firestore,我有一个名为channels的集合 用户被添加到userid数组中,记录也保存到名为serverId的字段中 我只需要一个新创建或更新的行列表来更新到我的本地房间数据库 每次发生任何更改时,我都会更新快照时间字段 之前我使用了以下代码,其中lastTime是本地房间db的最大值(快照时间) 它返回更新的字段,但不返回新记录 因此,我尝试此查询仅获取新行: 此处通道是本地数据库中所有通道SID的列表 现在遇到的错误是: 无效查询。不能将“array\u contains”筛选器与“not\u in
如何获得新创建的记录?这是因为
不在中应该与数组包含的内容一起使用。试图用Node.js重现此问题时,由于Firestore版本过期,我遇到了意外的错误消息。您能否确认Gradle依赖项om.google.firebase:firebase firestore是否在您的项目中的最新版本上。目前它是在实现'com.firebaseui:firebase ui auth:6.2.0'实现'com.google.firebase:firebase auth ktx:20.0.0'实现'com.google.firebase:firebase存储ktx:19.2.0'实现'com.google.firebase:firebase数据库ktx:19.5.1'实现'com.google.firebase:firebase存储ktx:22.0.0'
FirestoreUtil.chatChannelCollectionRef
.whereArrayContains("userIds", currentUserId)
//.whereGreaterThan("snapshotTime", lastTime)
.orderBy("snapshotTime", Query.Direction.ASCENDING)
.startAfter(lastTime)
.addSnapshotListener (activity) { snapshots, e ->
if (e != null) {
Log.e("exception occurred", "")
return@addSnapshotListener
}
for (dc in snapshots!!.documentChanges) {
when (dc.type) {
DocumentChange.Type.ADDED -> {
val chatChannel = dc.document.toObject(ChatChannel::class.java)
chatChannel.serverId = dc.document.id
repository.insertOrUpdateChannel(channelDao, chatChannel)
Log.e(TAG, "ADDED chatChannel: ${dc.document.data} - ${dc.document.id}")
}
DocumentChange.Type.MODIFIED -> {
val chatChannel = dc.document.toObject(ChatChannel::class.java)
chatChannel.serverId = dc.document.id
repository.insertOrUpdateChannel(channelDao, chatChannel)
Log.e(TAG, "MODIFIED chatChannel: ${dc.document.data} - ${dc.document.id}")
}
DocumentChange.Type.REMOVED -> {
val chatChannel = dc.document.toObject(ChatChannel::class.java)
chatChannel.serverId = dc.document.id
//MessageDatabase.getDatabase(AjoowebApplication.applicationContext()).runInTransaction {
repository.deleteChannel(channelDao, chatChannel)
Log.e(TAG, "REMOVED chatChannel: ${dc.document.data} - ${dc.document.id}")
}
else -> {
Log.e(TAG, "MISSING: ${dc.document.data} - ${dc.document.id}")
}
}
}
}
FirestoreUtil.firestoreInstance
.collection(FBCollections.CHANNEL_COL)
.whereNotIn("serverId", channels)
.whereArrayContains("userIds", currentUserId)
.get()
.addOnSuccessListener (activity) { snapshots ->
for (dc in snapshots!!.documents) {
val chatChannel = dc.toObject(ChatChannel::class.java)!!
chatChannel.serverId = dc.id
repository.insertOrUpdateChannel(channelDao, chatChannel)
Log.e(TAG, "LOADED chatChannel: ${dc.data} - ${dc.id}")
}
}