Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
How can I get only the users with roles of 'user'?

I am using Firebase for this app. Under each documents of a user, I have this array roles. For normal users, their roles would just be user. For an admin, it would be user and admin. I want to retrieve all of the normal users. However, the problem is that if I'll set it like this:

.collection("users")
.where("roles", "!=", "admin")

this will still show the user with an admin role.

enter image description here

How can I retrieve only those normal users and not the user with an admin role?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This would require an array-does-not-contain operation, which does not exist in Firestore.

You might want to consider storing the roles as a map with boolean values, so that you can query for where("roles.admin", "==", false).

Also see:

  • Firestore - Possible to query by array-not-contains?
  • FireStore - how to get around array "does-not-contain" queries
  • Angular Firestore | how to get array not contain
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use 'not-in' roles not in admin then you will get normal user

docs: https://firebase.google.com/docs/firestore/query-data/queries

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda