Hi, I try to upgrade my “forest-express-mongoose”: “6.7.2”, to “forest-express-mongoose”: “7.9.4”,
I followed this document Upgrade to v7 - Developer guide
But problem is I am getting some errors for some models like that
Cannot find the reference “Prices” on the model “Offers”.
because I was using my model just like below
const OffersSchema = new mongoose.Schema({
createdAt: {
type: Date,
default: Date.now
},
updatedAt: {
type: Date,
},
isActive: {
type: Boolean,
default: true,
},
name: {
type: String,
required: true,
},
meal: {
// meal type
type: Schema.Types.ObjectId,
ref: 'MealCategories',
},
prices: [{ type: Schema.Types.ObjectId, ref: 'Prices' }],
});
module.exports = mongoose.model('Offers', OffersSchema);
and I changed to
module.exports = (mongoose, Mongoose) => {
const OffersSchema = Mongoose.Schema({
createdAt: {
type: Date,
default: Date.now
},
updatedAt: {
type: Date,
},
isActive: {
type: Boolean,
default: true,
},
name: {
type: String,
required: true,
},
schoolReference: {
// school internal reference, ex: GE10
type: String
},
room: {
// room type
type: Schema.Types.ObjectId,
ref: 'RoomCategories',
},
meal: {
// meal type
type: Schema.Types.ObjectId,
ref: 'MealCategories',
},
prices: [{ type: Schema.Types.ObjectId, ref: 'Prices' }],
});
return mongoose.model('Offers', OffersSchema);
}
like that so I am using some references for other models for that reason I think it is related but I don’t know solution so could u help me ?