diff --git a/scripts/init-db.js b/scripts/init-db.js
index 003a87abd04d3e80c6123e90a0829842f9a973c6..6e97754fdee10a09841ce839e5794ed26e5ec690 100644
--- a/scripts/init-db.js
+++ b/scripts/init-db.js
@@ -122,7 +122,7 @@ const structuresSchema = mongoose.Schema({
// compile schema to model
const user = mongoose.model('users', usersSchema);
-const structuresType = mongoose.model('structureType', structuresTypeSchema);
+const structuresType = mongoose.model('structuretype', structuresTypeSchema);
const categories = mongoose.model('categories', categoriesSchema);
const structures = mongoose.model('structures', structuresSchema);
const jobs = mongoose.model('jobs', jobsSchema);
diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts
index 9a8459c706d4390e403ba2f10acc03b2135ddb91..50373dfa971370352134bdc5844e790497c1a6e1 100644
--- a/src/structures/services/structures.service.ts
+++ b/src/structures/services/structures.service.ts
@@ -85,6 +85,7 @@ export class StructuresService {
$and: [...this.parseFilter(filters), { deletedAt: { $exists: false }, accountVerified: true }],
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
} else if (filters?.length > 0 && multipleFilters?.length > 0) {
structures = await this.structureModel
@@ -94,6 +95,7 @@ export class StructuresService {
$and: [...this.parseFilter(filters), { deletedAt: { $exists: false }, accountVerified: true }],
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
} else if (filters?.length == 0 && multipleFilters?.length > 0) {
structures = await this.structureModel
@@ -102,6 +104,7 @@ export class StructuresService {
$or: [...this.parseFilter(multipleFilters), { deletedAt: { $exists: false }, accountVerified: true }],
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
} else {
structures = await this.structureModel
@@ -110,6 +113,7 @@ export class StructuresService {
$and: [{ deletedAt: { $exists: false }, accountVerified: true }],
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
}
@@ -136,6 +140,7 @@ export class StructuresService {
coord: position.coord,
})
.populate('personalOffers')
+ .populate('structureType')
.exec()
);
});
@@ -165,11 +170,13 @@ export class StructuresService {
],
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
} else if (filters) {
return this.structureModel
.find({ $and: [{ $and: this.parseFilter(filters), deletedAt: { $exists: false }, accountVerified: true }] })
.populate('personalOffers')
+ .populate('structureType')
.exec();
} else {
return this.structureModel
@@ -177,6 +184,7 @@ export class StructuresService {
$and: [{ $or: [{ $text: { $search: searchString }, deletedAt: { $exists: false }, accountVerified: true }] }],
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
}
}
@@ -233,13 +241,17 @@ export class StructuresService {
}
})
);
- return this.structureModel.find({ deletedAt: { $exists: false }, accountVerified: true }).exec();
+ return this.structureModel
+ .find({ deletedAt: { $exists: false }, accountVerified: true })
+ .populate('structureType')
+ .exec();
}
public async findAllUnclaimed(): Promise<UnclaimedStructureDto[]> {
const structures = await this.structureModel
.find({ deletedAt: { $exists: false } })
.populate('personalOffers')
+ .populate('structureType')
.exec();
const unclaimedStructures = [];
await Promise.all(
@@ -261,6 +273,7 @@ export class StructuresService {
const structures = await this.structureModel
.find({ deletedAt: { $exists: false } })
.populate('personalOffers')
+ .populate('structureType')
.exec();
await Promise.all(
structures.map((structure: StructureDocument) => {
@@ -278,6 +291,7 @@ export class StructuresService {
const structures = await this.structureModel
.find({ deletedAt: { $exists: false } })
.populate('personalOffers')
+ .populate('structureType')
.exec();
// Update structures coord and address before sending them
await Promise.all(
@@ -291,6 +305,7 @@ export class StructuresService {
coord: position.coord,
})
.populate('personalOffers')
+ .populate('structureType')
.exec();
});
}