Complete the code to embed an address document inside a user document.
db.users.insertOne({ name: "Alice", address: [1] })Embedding means placing the address document directly inside the user document as a sub-document.
Complete the code to reference an address document by its ObjectId in the user document.
db.users.insertOne({ name: "Bob", address_id: [1] })Referencing means storing the ObjectId of the related document instead of embedding the whole document.
Fix the error in the referencing code to correctly store the address reference.
db.users.insertOne({ name: "Carol", address_id: [1] })The address_id field must be an ObjectId type, not a string or array.
Fill both blanks to embed multiple phone numbers inside a user document.
db.users.insertOne({ name: "Dave", phones: [1] })
// Each phone is a [2]Phones are embedded as an array of objects, each object representing a phone with type and number.
Fill all three blanks to create a referencing pattern with user and address collections.
const user = {
name: "Eve",
address_id: [1]
};
const address = {
_id: [2],
street: "789 Pine St",
city: [3]
};The user references the address by ObjectId. The address document has the same ObjectId and a city name string.