Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda