Schema design for privacy settings in MongoDB I have a set of documents that can have various privacy settings around them:


They can be completed public (any registered user) can view them
They can be viewable only by people following you (this
"Followers" array is stored in each User's document)
They can be private to the person who published the document as well.
They can have custom privacy which allows you to name individual users who can view the document. In addition, you can allow groups of users to also view the document (e.g. there could be a group called "Sample Group" which has 20 users in it. You could allow said group to view the tile.)


I am lost as to how to implement a schema for this efficiently in MongoDB and would love some insight into best practices for implementing this schema.
Your documents can contain some inline privacy section-document or reference to that document in some security collection (for example) where you can specify whether to access.
On the assumption of your problem it can be looks like:

{
    "status":"private", // one of allow-all, private, deny-all
    "deny":[_id('user'),...],
    "allow":[_id('user'),..]
}


where "status" is the main policy for document witch will be handled with your code.
It is just an example. It can be done with many different ways.



Cheers.