定義
passwordPrompt()Prompts for the password in
mongosh. The entered password is not displayed in the shell. UsepasswordPrompt()in conjunction with methods that accept password as a parameter instead of specifying the password in cleartext to those methods.
例
passwordPrompt() を db.createUser() で使用する
db.createUser()ではパスワードを指定する必要があります。
You can use passwordPrompt() as the value for the pwd instead of specifying the password.
db.createUser( { user:"user123", pwd: passwordPrompt(), // Instead of specifying the password in cleartext roles:[ "readWrite" ] } )
パスワードの入力を求められたら、入力します。
passwordPrompt() を db.auth() で使用する
When you run the db.auth(<username>, <password>) command you can replace the password with the passwordPrompt() method.
db.auth(<username>, <password>)コマンドからパスワードを省略すると、ユーザーはパスワードの入力を求められます。
次の例では、shell に表示されていないパスワードの入力をユーザーに要求します。
db.auth("user123")
passwordPrompt() を db.changeUserPassword() で使用する
db.changeUserPassword()ではパスワードを指定する必要があります。
You can use passwordPrompt() instead of specifying the password.
db.changeUserPassword("user123", passwordPrompt())
パスワードの入力を求められたら、入力します。
passwordPrompt() を db.updateUser() で使用する
db.updateUser()を使用してパスワードを変更する場合、 メソッドではパスワードを指定する必要があります。
You can use passwordPrompt() as the value for the pwd instead of specifying the password.
db.updateUser( "user123", { pwd: passwordPrompt(), mechanisms: [ "SCRAM-SHA-256" ] } )
パスワードの入力を求められたら、入力します。