MongoDB adding users and roles to databases

To add users + roles


    // main admin user
    use admin
    db.createUser({ user: "***", pwd: passwordPrompt(), roles: [{ role: "root", db: "admin" }, { role: "dbOwner", db: "work_db" }] })

    // specific DB user
    use work_db
    db.createUser({ user: "***", pwd: passwordPrompt(), roles: [{ role: "dbOwner", db: "work_db" }] })

Connection string

connectionURI = "mongodb://user:pass@localhost:27017/?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=WORK_DB&authMechanism=SCRAM-SHA-256"