there are 2 collection book and category:
category Schema
Category = mongoose.Schema({
categoryName: {
type: String,
require: true
},
isActive: {
type: Boolean
}
});
Book schema
const Book = mongoose.Schema({
categoryId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'category',
require: true
},
bookName: {
type: String,
require: true,
},
bookAuthor: {
type: String,
require: true,
},
bookPrice: {
type: Number,
require: true,
},
bookLanguage: {
type: String,
require: true,
}
});
I want to fetch all book records with the category name instead of objectId of category schema.