I would want to exclude some documents from a GET request, so I have written the following code (note the line users = users.where(admin.firestore.FieldPath.documentId(), '!=', k);
):
let users = admin_firestore.collection('users');
const likes = admin_firestore.collection('likes_of_users_posts');
likes.get().then(function(likes_docs) {
const map_users_id_with_number_of_likes = [];
likes_docs.forEach(like_doc => {
if(!(like_doc.data().post_owner in map_users_id_with_number_of_likes)) {
map_users_id_with_number_of_likes[like_doc.data().post_owner] = 0;
}
map_users_id_with_number_of_likes[like_doc.data().post_owner] += 1;
});
Object.keys(map_users_id_with_number_of_likes).forEach((k) => {
users = users.where(admin.firestore.FieldPath.documentId(), '!=', k);
});
It's part of my Google Cloud Functions function.
When, in the Android app, I execute this Cloud Function function, I can see the following error, in the logs:
Error: Value for argument "opStr" is invalid. Acceptable values are: <, <=, ==, >, >=, array-contains
However I really need towrite something equivalent to: "different than X AND different than Y AND...". So to chain the .where(admin.firestore.FieldPath.documentId(), '!=', k)
as I did.