-
-
Save ajduke/5898857 to your computer and use it in GitHub Desktop.
including the which is current database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prompt = function() { | |
// set version | |
version = db.version(); | |
dbName = db.getName() | |
// case mongos | |
if (rs.status().info == 'mongos') { | |
return rs.status().info + ':[' + version + '] > '; | |
} | |
// config or replica | |
if (rs.status().set) { | |
role = rs.status().set; | |
} else { | |
role = 'config'; | |
return role + ':[' + version + '] > '; | |
} | |
// for replicasets | |
switch (rs.status().myState) { | |
case 1: | |
stateStr = 'PRIMARY'; | |
break; | |
case 2: | |
stateStr = 'SECONDARY'; | |
break; | |
case 7: | |
stateStr = 'ARBITER'; | |
break; | |
} | |
return role + ':' + stateStr + ':[' + version + ']'+':' + dbName +'> ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment