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

231
Vistas
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 Respuestas
Responde la pregunta

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 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