I'm talking specifically about nods with MongoDB (I know that the MongoDB schema is low, but We structure the data for a realistic moment about its importance).
Is there some magic solution to reduce the number of queries in a database related to authenticating users? For example, if the business logic of my application is necessary to ensure that the user has the necessary privileges to update / retrieve data from a particular document or archive, then do the database without having to make two calls Any way? To check the user's rights, and to get the other data needed?
Edit: Another question triggers-happy-closed moderators. I agree that the question is abstract, but I do not think it is "the real question" to put it simply: In the role-based applications, the best way to reduce the number of calls to a database What's the way, especially in the context of nodsjs + mongdibi? Can it be done? Or is role-based access control disabled and clumsy for NodeJS + MongoDB? Obviously, you know that he holds a document that steals I think this document In the beginning of the session you have a user who has a field in the beginning of the session, such as: Can ask for roles. Say '<' user: 'shennan', 'roles': ['user', 'west coast', 'sale']} You can store that list of roles in the user's session. In that hand, whatever has been left, adds roles with a Where the value of the operator is the user session In the Mongo console taken from, the code to use it for itself is here: The document 'foo3' can not be read by anyone in the sale: < Pre>
{'foo': 'bar' 'canRead': 'sales'}
$ in operator:
db.test.find ({'canRead': {'$ In': User ',' west coast ',' sale ']})
& gt; Db.test.find ({'canRead': {'$ in': ['user', 'west coast', 'sale']}}, {_id: 0}) {"foo": "bar", " ("Hr", "sale"]}
No comments:
Post a Comment