There could be multiple reasons if the above error message have been observed. To help you with the correct solution, could you provide the following information regarding the deployment?
The user created for the deployment. You can read about createUser and getUser from the attached documentation.
The roles granted to the user. The documentation on Build-in user roles would help you to understand more on roles and authentication.
The query used on the database which generates the above error and on which database the query is applied .
The connection URI used to connect to the Atlas cluster.
Please note that, if you are using the above query on the admin database, this activity is restricted from the MongoDB server, as the Admin, local, config are used for the internals of MongoDB.
Also, for shared tiers(M0/M2/M5), there might be some operation limitations which you can refer for further understanding.
MongoError: (Unauthorized) not authorized on admin to execute command { find: "sections", filter: { }, ..., $db: "admin" }
The issue appears to be that you’re trying to query a namespace you don’t have access to. If you connected to your cluster using a connection string such as mongodb+srv://<user>:<pass>@xxx.mongodb.net/ the database the MongoClient will try to use will be the admin database (by default when authentication is used).
You can see this in the error you provided ($db: "admin"), so the easiest way to address this is to provide a database in the connection string (mongodb+srv://<user>:<pass>@xxx.mongodb.net/myDatabase).
By adding a database name to the connection string the query you were attempting will target myDatabase.sections, which your user should have full access to as opposed to admin.sections, which would be restricted (as it is in the admin database).
As you’re new to MongoDB and MongoDB Atlas it’s worth noting there are Unsupported Commands in Atlas (such as createUser) that may be available in standalone deployments.