What is this system.views collection?
As per percona blog here MongoDB 3.4
views are non-materialized views, and behind the scenes the engine runs an aggregation. Creating a view requires that we specify a collection or a previous existing view. When a view is the source collection from another view, it allows us to execute a chained aggregation.
To create a view, we should use the db.createView(‘view_name’,’source’,[pipeline])
command, specifying the view name, the view source collection and the aggregation pipeline. This aggregation pipeline, as well as the other parameters, is saved in the system.views collection. This is the only space that the view will use in the system. A new document is saved in the system.views collection for each view created.
Views appear as a collection when we are listing them. The show collections command shows us views as one collection, but such collections are read-only. To drop a view, we simply execute db.collection.drop(). The collection is removed from the system.collections, but the data remains untouched because it only removes the code that generates the view result.
How can I get my admin user authorised to run command on this collection?
use admin
db.runCommand({ createRole: "readViewCollection",
privileges: [
{ resource: { db: "", collection: "system.views" }, actions: [ "find"] }],
roles : []
})
db.grantRoleToUsergrantRolesToUser('<your_user>',['readViewCollection']);