Complete the code to insert a document with an array field into the collection.
db.students.insertOne({ name: "Alice", grades: [1] })The grades field must be an array, so square brackets [] are used to define it.
Complete the code to insert multiple documents with arrays into the collection.
db.students.insertMany([ { name: "Bob", courses: [1] }, { name: "Carol", courses: ["Math", "Science"] } ])The courses field must be an array, so square brackets [] are used to list the course names.
Fix the error in the code to correctly insert a document with an array field.
db.students.insertOne({ name: "Dave", hobbies: [1] })The hobbies field must be an array, so it needs square brackets with each hobby as a string.
Fill both blanks to insert a document with an array of objects representing books.
db.library.insertOne({ owner: "Eve", books: [ { title: [1], pages: [2] } ] })The title must be a string with quotes, and pages is a number without quotes.
Fill all three blanks to insert multiple documents with arrays of tags.
db.posts.insertMany([ { title: [1], tags: [2] }, { title: [3], tags: ["mongodb", "database"] } ])Titles are strings with quotes. Tags are arrays with square brackets and strings inside.