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

221
Views
Sequelize - Is there any way to do Data Abstraction/Filtering?

First at all, I'm sorry if I'm re-posting, but I couldn't find anything related.

I'm working on a application that handle very sensitive data. I want to filter this data by user's role.

I've done this (in another job) using Doctrine Filters, but I can't find any information about how to do this using Sequelize (over PostgreSQL).

Eg:

sensitive_information:

| user_id | sensible_value |
+---------+----------------+
| 1       | something      |
| 2       | something_else |

I need this:

SELECT *
  FROM sensitive_information
  WHERE user_id = 1; /** I need this to be added automatically in all
                         queries to sensitive_information */

So, user 1 never will see information of another user. That's the goal.

Is it possible? I'm open to suggestions.

Thanks in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This can be addressed by using Sequelize scopes.

Since scopes can be functions:

Scopes are defined in the model definition and can be finder objects, or functions returning finder objects

it's easy to define a scope that filters information according to the user that is logged in.

I haven't implemented this exactly scope yet but I have a good idea on how to address it if anyone needs helps with it.

over 4 years ago · Santiago Trujillo 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!