What does the bracket mean in mongo shell command db.serverStatus()['repl']

In the lecture Lecture: Replication Commands at 2:53.
What do the brackets after db.serverStatus()[‘repl’] mean? where can I find the documentation about this usage?

Hey @Ziwen_Song_32480

The mongo shell is a Javascript interpreter

The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mongo shell to query and update data as well as perform administrative operations.

Therefore the syntax you are asking about is Javascript.

db.serverStatus()['repl']
Means
db = db object.
.serverStatus() = run the serverStatus method(function) on the db object
['repl'] = from the returned object of the above method(funciton) give me the repl value.

2 Likes

Thank you so much.

1 Like

Closing this thread as the issue has been resolved. Please feel free to create another thread if you have any query.