- Creazione pagina Home logout
- Nuovo Gasordine - Visualizzazione GAS / BOTTEGA
This commit is contained in:
@@ -35,6 +35,9 @@ const productSchema = new Schema({
|
||||
idStorehouses: [
|
||||
{ type: Schema.Types.ObjectId, ref: 'Storehouse' }
|
||||
],
|
||||
idGasordines: [
|
||||
{ type: Schema.Types.ObjectId, ref: 'Gasordine' }
|
||||
],
|
||||
idScontisticas: [
|
||||
{ type: Schema.Types.ObjectId, ref: 'Scontistica' }
|
||||
],
|
||||
@@ -42,6 +45,7 @@ const productSchema = new Schema({
|
||||
code: {
|
||||
type: String,
|
||||
unique: true,
|
||||
required: true,
|
||||
},
|
||||
codice_EAN: {
|
||||
type: String,
|
||||
@@ -93,6 +97,10 @@ const productSchema = new Schema({
|
||||
unit: {
|
||||
type: Number
|
||||
},
|
||||
minBuyQty: { // quantità minima acquistabile
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
stockQty: { // in magazzino
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -164,7 +172,10 @@ var Product = module.exports = mongoose.model('Product', productSchema);
|
||||
productSchema.index({ idapp: 1 });
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string }]
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
@@ -232,6 +243,20 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
localField: 'idGasordines',
|
||||
foreignField: '_id',
|
||||
as: 'gasordines'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
|
||||
Reference in New Issue
Block a user