An error was reported when the mongoDB database inserted data: db.collection is not a function

  mongodb, question

The code is as follows:图片描述

After execution, an error was reported in the terminal, as shown in the following figure:
图片描述

Please give directions, thank you

Should you choose a database first?var db = db.db("mydb");