"firebase.firestore().collection().where(_, _, *) 'value' is not a valid filter. The 'not-in' filter supports up to 10 elements in the value array."
P粉833546953
2023-09-04 22:44:17
<p>firebase.firestore().collection().where(_, _, *) 'value' is invalid. The "not-in" filter supports up to 10 elements in the value array. </p>
<pre class="brush:php;toolbar:false;">unlanguages = firestore()
.collection("users")
--> .where("id", "not-in", [...passedUserIds, ...smashesUserIds])
.onSnapshot(async querySnapshot => {
if (querySnapshot?.docs?.length > 0) {
let dondur2 = await querySnapshot?.docs
.filter((doc) => doc.id != user.uid)
.filter((doc) => doc._data.gender != loggedInProfile.gender)
.filter((doc) => doc._data.age <= `${value[1]}`)
.filter((doc) => doc._data.age >= `${value[0]}`)
.filter((doc) =>
doc._data.languages[0] == languages ||
doc._data.languages[1] == languages ||
doc._data.languages[2] == languages ||
doc._data.languages[3] == languages ||
doc._data.languages[4] == languages ||
doc._data.languages[5] == languages ||
doc._data.languages[6] == languages ||
doc._data.languages[7] == languages
)
.map((doc) => ({ id: doc.id, ...doc.data() }))
setProfiles(dondur2)
}
})</pre>
<p>So there is a problem here, 'ids' exceeds 10, how should I solve it? I looked at other questions but it didn't work for me. </p>
The translation of this sentence is as follows:
You most likely have more than 10 elements in the
[...passedUserIds, ...smashesUserIds]
array.This is a limitation of Firestore. The only way to get around this limitation is to either adjust your data model or find a way to reduce the number of elements in the array. Without seeing real examples of your data, it's difficult to give further advice.