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

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

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