Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
Operate multiple in operations in Firestore. Any hack possible?

I want to query on multiple fields based on multiple in conditions as shown below:

db
    .collection(firebasePaths.funfuse_verified_users)
    .orderBy('uid')
    .where('uid', 'not-in', notToIncludeAccounts)
    .orderBy('skills')
    .where('skills', 'in', skills)
    .orderBy('interests')
    .where('interests', 'in', interests)

Firestore limitation states that only one in is allowed per query but I was interested in knowing if by some hacky way can I make this work? One thing I thought of is to fetch the two results and then take the intersection of those but this would mean a lot of load on my backend. Is there some other way that I am not aware of which could be used for such scenarios? I want to filter the database based on skills and interest arrays.

Edit 1: Added Document Example Example of the document will be something like this:

{
      "name": "Shivam",
      "online": true,
      "bio": "",
      "skills": [
        "Supply Chain",
        "Inventory Management",
        "Legal",
        "Digital Marketing",
        "Web"
      ],
      "interests": [
        "Healthcare"
      ],
      "imageLoc": "profile-pics/profile-photo",
      "isImageAvailable": true,
      "uid": "",
      "username": "tttt"
    },

Expected query:

db
    .collection(firebasePaths.funfuse_verified_users)
    .orderBy('uid')
    .where('uid', 'not-in', ['1','2'])
    .orderBy('skills')
    .where('skills', 'in', ["Supply Chain","Inventory Management"])
    .orderBy('interests')
    .where('interests', 'in', ["Supply Chain","Inventory Management"])

Something like this.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is nothing hidden in the API to allow the use-case, so any workaround will have to come from changes to the data model.


The best I can think of is to add an additional field that combines the skills and interests values, and filter on that.

If you just add all the individual values ("skills_and_interests": ["Supply Chain", "Inventory Management", "Legal", "Digital Marketing", "Web", "Healthcare"]), you can do the equivalent of an OR operation on that with in. If you want to be able to distinguish skills from interesting, you could prefix the values ("skill_Supply Chain", "interest_Healthcare").

If you want to filter on combined values, you'd have to add the combinations of skills and interests (e.g. "Supply Chain_Healthcare", "Inventory Management_Healthcare"), so that you can then do an AND like operation.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda