Complete the code to create a new document in Express using Mongoose.
const newUser = new User({ name: 'Alice', age: 25 });
newUser.[1]();The save() method saves the new document to the database.
Complete the code to create and save a new product document asynchronously.
async function addProduct() {
const product = new Product({ name: 'Book', price: 15 });
await product.[1]();
}Using await product.save() saves the new product document asynchronously.
Fix the error in the code to correctly create a new user document.
const user = new User({ username: 'john' });
user.[1]();You must use new User() to create a document instance before calling save().
Fill both blanks to create and save a new blog post document with a title and content.
const post = new Post({ title: [1], content: [2] });
await post.save();The title should be a string like 'Hello World' and content a string like 'This is my first post.' to create a meaningful blog post.
Fill all three blanks to create a new comment document and save it asynchronously.
async function addComment() {
const comment = new Comment({
author: [1],
text: [2],
date: [3]
});
await comment.save();
}The author and text are strings, so they need quotes. The date is a Date object created with new Date().