Populating businessOwner before sorting to avoid sorting issue
MODIFY
src/storage/mongodb/BillingStorage.ts
src/storage/mongodb/BillingStorage.ts
@@ -290,6 +290,11 @@ export default class BillingStorage {
}
// Remove the limit
aggregation.pop();
+ // Add Users
+ DatabaseUtils.pushUserLookupInAggregation({
+ tenantID: tenant.id, aggregation: aggregation, asField: 'businessOwner', localField: 'businessOwnerID',
+ foreignField: '_id', oneToOneCardinality: true, oneToOneCardinalityNotNull: false
+ });
// Sort
if (!dbParams.sort) {
dbParams.sort = { _id: 1 };
@@ -305,11 +310,6 @@ export default class BillingStorage {
aggregation.push({
$limit: dbParams.limit
});
- // Add Users
- DatabaseUtils.pushUserLookupInAggregation({
- tenantID: tenant.id, aggregation: aggregation, asField: 'businessOwner', localField: 'businessOwnerID',
- foreignField: '_id', oneToOneCardinality: true, oneToOneCardinalityNotNull: false
- });
// Add Last Changed / Created
DatabaseUtils.pushCreatedLastChangedInAggregation(tenant.id, aggregation);
// Handle the ID

Populating businessOwner before sorting to avoid sorting issue