Q:

Mongoose .populate()

I am a beginner.
I have two mongoose schema, orders and customers.
orders schema
const mongoose = require("mongoose");

const orderSchema = new mongoose.Schema({
    customer: {type: mongoose.Schema.Types.ObjectId, ref: "Customer"}    
});

module.exports = mongoose.model("Order", orderSchema);

customers schema
const mongoose        = require("mongoose"),
passportLocalMongoose = require("passport-local-mongoose");

const customerSchema = new mongoose.Schema({
    name: String,
    email: String
    username: String,
    password: String
});

customerSchema.plugin(passportLocalMongoose);
module.exports = mongoose.model("Customer", customerSchema);

This is my code when I insert new order
const Orders = require("../models/orders");

Orders.create({customer: req.user});

I want to console.log() all the orders and customers by using .populate()
Here is my code
Orders.find({}).populate("customers").exec((err, order) => {
    if(err) {
        console.log(err);
    } else {
        console.log(order);
    }
});

I want to get the customer's id, name, and email but the problem is I only get the customer's id

A:

Orders.find({}).populate("customer").exec((err, order) => {
if(err) {
    console.log(err);
} else {
    console.log(order);
}
})

or you can try

    Orders.find({}).populate({path:"customer"}).exec((err, order) => {
if(err) {
    console.log(err);
} else {
    console.log(order);
}

}) 

