Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!