Now it is time to populate the database with some tasks.
You could run the command line interface of your database and enter some MongoDB queries. But this is risky and not very handy. It becomes especially true when the complexity of your models increases.
That's why you are going to create and use a shell script instead.
A shell script is a piece of code intended to be called from the command line. It has access to all the components of your application, including your models. A shell script is divided in two parts:
schemaobject which defines the specification of the command line arguments,
- and a
mainfunction which gets these arguments as an object and executes some code.
Open the new generated file in the
src/scripts directory and update its content.
Build the script.
Then run the script to create tasks in the database.
Note that if you try to create a new to-do without specifying the text argument, you'll get the error below.
Error: The command line arguments should have required property 'text'.