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

225
Vistas
Record level security mongodb

I have some kind of data structure for my model for now, I m still figuring out along the way, but one of the concerns is that I need to serve the data from the mongo based on the user logged in.

One of the approaches I had in mind was something like this, if my object(s) looked like this in mongo:

{
  record_id: 1,
  property_1: 'some value',
  property_2: 'some value',
  users: [1, 2, 3, 4]
  ...
}

And then another one:

{
  record_id: 2,
  property_1: 'some value 2',
  property_2: 'some value 2',
  users: [1, 2]
  ...
}

Then on some page that I have I can display all the records for a given user.

But I have a requirement where I could give some users access to more records and/or to less. How would I go about doing this?

If I had a case where I would need to take away the access from x amount of records, and give access to the y amount of records, for a user. In a relational database I would do something like this :

--start transaction--
remove all access for a given user from the records
add all new access
--transaction end--

So in case user refreshes the page, he or she can only see the old data before the access for that user was updated, or the new data which would happen only after entire transaction would complete.

How do you guys do this in a mongo world? Do I change how I store the records, or the way I manage row level security per user, and manage that access?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could try using the redact operator. So everytime you need to change security for a document rather than an entire collection or even a database, you can use redact to control access for just

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