$lookup work in MongoDB but doenst work with mongoose $lookup work in MongoDB but doenst work with mongoose mongoose mongoose

$lookup work in MongoDB but doenst work with mongoose


@Anthony Winzlet was correct, should be categories (in the pural) would have to leave categories (in the pural) and not category, but also, i had not defined the categoryId field as being an ObjectId in the Product Schema, so it was comparing string with ObjectId. In the tests in the terminal I had saved the server return, which returns the _id fields as strings. Now it's working.Thanks!

const ProductSchema = new Schema({    name: { type: String, required: true },    cod: String,    storeKey: { type: String, required: true },    categoryId: { type: Schema.Types.ObjectId, ref: 'categories' },    description: { type: String, required: true },    price: { type: Number, required: true },    stockQuantity: { type: Number, required: true },    avatar: String,    visible: Boolean}, {        timestamps: true    });