MongoDB and Mongoose - Create and Save a Record of a Model - not authorized on admin to execute command

MongoDB and Mongoose - Create and Save a Record of a Model - not authorized on admin to execute command
0

Hi everyone i get this error

not authorized on admin to execute command { insert: "people", documents: [[{favoriteFoods [meat fish]} {_id ObjectIdHex("5d9904581c23c22d3bf20250")} {name Jose} {age 33} {__v 0}]], ordered: true, writeConcern: { w: "majority" }, lsid: { id: {4 [19 82 53 148 209 226 71 104 167 81 65 63 73 147 147 123]} }, txnNumber: 2.000000, $clusterTime: { clusterTime: 6744426632838119425, signature: { hash: [48 69 194 102 128 1 231 107 174 196 155 112 100 155 165 114 241 8 165 143], keyId: 6743788125820026880.000000 } }, $db: "admin" }

This is my code so far:

const mongoose = require("mongoose");
mongoose.connect(process.env.MONGO_URI, { useUnifiedTopology: true, useNewUrlParser: true });

var Schema = mongoose.Schema;
var personScheme = new Schema({
  name: String,
  age: Number,
  favoriteFoods: [String]
});

const Person = mongoose.model("Person", personScheme);

var createSomePerson = function(done) {
  const facu = new Person({
    name: "Facundo",
    age: 25,
    favoriteFoods: ["Banana", "Chips"]
  });
  facu.save((err, data) => (err ? done(err) : done(null, data)));
};


var createAndSavePerson = function(done) {
  const jose = new Person({
    name: "Jose",
    age: 33,
    favoriteFoods: ["meat", "fish"]
  });
  jose.save(function(err, data) {
    if (err){
      console.log(err)
      done(err)
    }
    done(null, data)
  });
};

And this is my .env file:

And this is how my Network Access and Database Access look like.

Also here is the glitch link: https://glitch.com/edit/#!/join/0891013c-901f-43b6-b4fe-b7eae9fdf960

Can anyone help me understand whats wrong?

You should not publish your database admin passwords as someone could lock you out of your database.

i thought i edited out the password in the .env file? that PASSWORD was not my real password

I’m not sure if you have found a solution, but I am running into the same problem. I noticed you don’t have your MONGO_URI in quotes, so that may help.