Database

MongoDB has an absolutely fine syntax. Inserting a record and inserting many record syntax isn’t doesn’t have much of a difference.

This is how you insert a row in MongoDB

> db.books.insert({
  title: 'Book Title',
  category: 'Fiction',
  tags: ['children', 'fantasy'],
  user: {
    name: 'Sophia',
    status: 'author'
  },
  date: Date()
})
WriteResult({ "nInserted" : 1 })

You should use the insertMany method on the collection to insert multiple rows in MongoDB.

> db.books.insertMany([{
  title: 'Book Title 2',
  category: 'Fiction',
  tags: ['teen', 'fantasy'],
  user: {
    name: 'Ryan',
    status: 'author'
  },
  date: Date()
},
{
  title: 'Book Title 3',
  category: 'Non-Fiction',
  tags: ['history', 'documentary'],
  user: {
    name: 'Arthur',
    status: 'author'
  },
  date: Date()
},
{
  title: 'Book Title 4',
  category: 'Non-Fiction',
  tags: ['legal'],
  user: {
    name: 'Manuel',
    status: 'author'
  },
  date: Date()
}])

{
	"acknowledged" : true,
	"insertedIds" : [
		ObjectId("5d5e21a47545de885fa391fc"),
		ObjectId("5d5e21a47545de885fa391fd"),
		ObjectId("5d5e21a47545de885fa391fe")
	]

Showing the rows confirms that our action succeeded

> db.books.find()
{ "_id" : ObjectId("5d5e1c357545de885fa391fb"), "title" : "Book Title", "category" : "Fiction", "tags" : [ "children", "fantasy" ], "user" : { "name" : "Sophia", "status" : "author" }, "date" : "Thu Aug 22 2019 12:38:12 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21467545de885fa391fc"), "title" : "Book Title 2", "category" : "Fiction", "tags" : [ "teen", "fantasy" ], "user" : { "name" : "Ryan", "status" : "author" }, "date" : "Thu Aug 22 2019 12:59:50 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21a47545de885fa391fd"), "title" : "Book Title 3", "category" : "Non-Fiction", "tags" : [ "history", "documentary" ], "user" : { "name" : "Arthur", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21a47545de885fa391fe"), "title" : "Book Title 4", "category" : "Non-Fiction", "tags" : [ "legal" ], "user" : { "name" : "Manuel", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }

To make things prettier, we can use the pretty method

> db.books.find().pretty()
{
	"_id" : ObjectId("5d5e1c357545de885fa391fb"),
	"title" : "Book Title",
	"category" : "Fiction",
	"tags" : [
		"children",
		"fantasy"
	],
	"user" : {
		"name" : "Sophia",
		"status" : "author"
	},
	"date" : "Thu Aug 22 2019 12:38:12 GMT+0800 (PST)"
}
{
	"_id" : ObjectId("5d5e21467545de885fa391fc"),
	"title" : "Book Title 2",
	"category" : "Fiction",
	"tags" : [
		"teen",
		"fantasy"
	],
	"user" : {
		"name" : "Ryan",
		"status" : "author"
	},
	"date" : "Thu Aug 22 2019 12:59:50 GMT+0800 (PST)"
}
{
	"_id" : ObjectId("5d5e21a47545de885fa391fd"),
	"title" : "Book Title 3",
	"category" : "Non-Fiction",
	"tags" : [
		"history",
		"documentary"
	],
	"user" : {
		"name" : "Arthur",
		"status" : "author"
	},
	"date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)"
}
{
	"_id" : ObjectId("5d5e21a47545de885fa391fe"),
	"title" : "Book Title 4",
	"category" : "Non-Fiction",
	"tags" : [
		"legal"
	],
	"user" : {
		"name" : "Manuel",
		"status" : "author"
	},
	"date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)"
}

Pretty!