In MongoDB a collection is automatically created when it is referenced in any command. For example, if you run an insert command : db. student . insert ({ name : " Viraj " }) Above command will create a collection named student if it doesn't exist already in the database. But we can explicitly create a collection using the createCollection() command. The syntax of createCollection method is : db. createCollection ( name , options ) In the above command, name will be the name of the collection and options is a document which can be used to specify configurations for the collection. options parameter is optional, and you can simply create a collection by just providing a name for the collection. But if you want to configure your collection, you can use various options available to do so. Following are the available configuration options for creating a collection in MongoDB : Field Type Description capped boolean (Option...
Modes of Unix Vi Editor The vi editor has three modes of operation viz. the command mode, the insert mode, and the ex-command mode. #1) Command mode: In this mode, all the keys work as commands. These keys are used for inserting, appending, deleting, opening new lines, moving the cursor over the paragraphs and sentences, etc. In this mode, the keys are not displayed but each key performs an operation. By default the vi editor is in command mode, hence we cannot type text in command mode. In order to write programs or text in vi editor, we need to switch to the insert mode which can be done by pressing the escape button. #2) Insert mode: In this mode, we can insert, append, edit or replace texts. We can switch from the command mode to Insert mode by pressing the escape button and then press I or A to enter into insert mode. #3) Ex command mode: This mode is used for entering commands at the bottom line of the vi editor called as a command line. To switch to Ex command ...
Unix Conditional Statements The if-elif-fi Unix provides a number of relational operators in addition to the logical operators mentioned earlier. These can be used to compare numeric values. -lt less than -le less than or equal to -gt greater than -ge greater than or equal to -eq equal to -ne not equal to Unix provides a number of ways for conditionally executing the other commands. These are covered below: #1) The if statements Example: if <control command> then <statements> fi #2) The if…else statements Example: if <control command> then <statements> else <statements> fi #3) The if…elif…else…fi statement Example: if <control command> then <statements> elif then <statements> else <statements fi Given below are some example programs that illustrate these conditional statements: #1) Check if an input number is positive: $ echo “Enter a number” $ read num $ if [ $num -gt 0 ] $ t...
Comments
Post a Comment