Here is my schema
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const finalDocument = new Schema({
name: {
type: String,
},
Properties: {
type: mongoose.Schema.Types.ObjectId,
ref: "Properties",
},
borrower: {
type: mongoose.Schema.Types.ObjectId,
ref: "borrowers",
},
});
var FinalDocuments = mongoose.model("finalDocument", finalDocument);
module.exports = FinalDocuments;
and here are my routes.
finalDocument
.find({})
.populate("borrower")
.exec()
.then((brws) => {
res.statusCode = 200;
res.setHeader("Content-Type", "application/json");
res.json(brws);
})
.catch((err) => {
console.log("error in getting borrowers", err);
});
and when I am calling this route, borrower is not populated. I am attaching the picture of Postman.