javascript - using populate to display username instead of id -
i'm running expressjs mongoosejs made connection between collections customerid below: . . /** * customer schema */ var customerschema = new schema({ id : number, name: string, joined: { type: date, default: date.now }, city: string }); mongoose.model('customer', customerschema); . . /** * order schema */ var orderschema = new schema({ id : number, products: [schema.types.mixed], total: number, comments: string, customerid: {type: number, ref: 'customer'} }); mongoose.model('order', orderschema); . . exports.customerorders = function (req, res) { return order.find({customerid: req.params.customerid}, function (err, orders) { order.populate(orders, {path: 'customerid', model: 'order'}, function (err, orders) { if (!err) { return res.json(orders); } else { return res.send(err); } }); }); }; the above code generate following error: { m...