subcatprod

This commit is contained in:
Surya Paolo
2024-01-12 13:02:59 +01:00
parent 9b4a9dbf28
commit c63e345285
7 changed files with 122 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ const productInfoSchema = new Schema({
type: String,
},
idCatProds: [{ type: Schema.Types.ObjectId, ref: 'CatProd' }],
idSubCatProds: [{ type: Schema.Types.ObjectId, ref: 'SubCatProd' }],
color: {
type: String
},
@@ -131,6 +132,14 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
as: 'catprods'
}
},
{
$lookup: {
from: 'subcatprods',
localField: 'idSubCatProds',
foreignField: '_id',
as: 'subcatprods'
}
},
{
$sort: {
name: 1 // 1 for ascending order, -1 for descending order