Below code should solve your purpose
// Declare Address Schema
const addressSchema = new Schema({
location: String,
type: String
})
//create a model for Address
const Address = model(âAddressâ, addressSchema)
const userSchema = new Schema({
id: String,
name: String,
address: { type: String, ref: âAddressâ }
})
const User = model(âUserâ, userSchema)
// create an address
const address1 = new Address({
location : âsomelocationâ,
type : âresidentialâ
})