a. Screenshot from config file lecture:
Screenshot from config file documentation:
The Config File is written in YAML and YAML allows strings to be written with/without
quotes under certain conditions. Refer to the YAML documentation to understand quoting. As a guideline, if the MongoDB Config File documentation states that the parameter is a <string>
or the string contains spaces, it’s good programming practice to enclose it in quotes. There are also certain Config File options that require specific type of quotes. Generally, quotes act as a boundary and are used when parsing text.
Screenshot from rs.add()
If you follow the advice above re what to do when you see <string>
, you’ll be fine in this scenario too. Here it’s not using YAML so quotes are mandatory.
In the vagrant prompt you’re running under an Ubuntu Linux environment and quotes are required under certain conditions. If you recall what I mentioned earlier, if the string contains a space it must be quoted otherwise it will think that the character after the space is another option being passed. In the case of username there’s no space so quotes can be omitted. A Windows terminal follows similar rules.
So again, quote when you know that the parameter/argument is a <string>.