1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
function prompt() { var username = ""; var user = db.runCommand({ connectionStatus: 1 }).authInfo.authenticatedUsers[0]; if (!!user) { username = user.user; } else { username = "anonymous"; } var database = db.getName(); return `${username}:${database} >`; }