Doubts about views

Hi, I would like to understand the benefit of using views, other than having like a predefined aggregation pipeline already define. Because, if for example I am using the pipeline on a NodeJS app, that retrieves some info. In this case using the view, or the pipeline will be the same right? As they both calculate the results on the fly.

The resulting data essentially will be the same.

However when it comes to user roles, you can create a user role that only has access to specific views, and not the underlying collection/s.

The example given in “Chapter 5: Miscellaneous Aggregation: Views” was a large corporation hiring a temporary staffing agency to assist with a phone promotion. You do not want to give them the ability to access sensitive info.

How do you assign roles to users with particular views? @jcarlosgarcia


I believe you could assign roles to users on a specific view as you would do with collections, the view would be the collection in the privileges array. Let me elaborate an example and I will post it asap.

José Carlos