@opra/mongodb 0.33.9 → 0.33.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -306,20 +306,25 @@ class MongoCollectionService extends mongo_service_js_1.MongoService {
306
306
  };
307
307
  const limit = options?.limit || this.defaultLimit;
308
308
  const stages = [];
309
+ let filter;
310
+ if (options?.filter)
311
+ filter = mongo_adapter_js_1.MongoAdapter.prepareFilter(options?.filter);
309
312
  let dataStages = stages;
310
313
  if (options?.count) {
311
314
  dataStages = [];
315
+ const count = [];
316
+ if (filter)
317
+ count.push({ $match: filter });
318
+ count.push({ $count: 'totalMatches' });
312
319
  stages.push({
313
320
  $facet: {
314
321
  data: dataStages,
315
- count: [{ $count: 'totalMatches' }]
322
+ count,
316
323
  }
317
324
  });
318
325
  }
319
- if (options?.filter) {
320
- const filter = mongo_adapter_js_1.MongoAdapter.prepareFilter(options?.filter);
326
+ if (filter)
321
327
  dataStages.push({ $match: filter });
322
- }
323
328
  if (options?.skip)
324
329
  dataStages.push({ $skip: options.skip });
325
330
  if (options?.sort) {
@@ -302,20 +302,25 @@ export class MongoCollectionService extends MongoService {
302
302
  };
303
303
  const limit = options?.limit || this.defaultLimit;
304
304
  const stages = [];
305
+ let filter;
306
+ if (options?.filter)
307
+ filter = MongoAdapter.prepareFilter(options?.filter);
305
308
  let dataStages = stages;
306
309
  if (options?.count) {
307
310
  dataStages = [];
311
+ const count = [];
312
+ if (filter)
313
+ count.push({ $match: filter });
314
+ count.push({ $count: 'totalMatches' });
308
315
  stages.push({
309
316
  $facet: {
310
317
  data: dataStages,
311
- count: [{ $count: 'totalMatches' }]
318
+ count,
312
319
  }
313
320
  });
314
321
  }
315
- if (options?.filter) {
316
- const filter = MongoAdapter.prepareFilter(options?.filter);
322
+ if (filter)
317
323
  dataStages.push({ $match: filter });
318
- }
319
324
  if (options?.skip)
320
325
  dataStages.push({ $skip: options.skip });
321
326
  if (options?.sort) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/mongodb",
3
- "version": "0.33.9",
3
+ "version": "0.33.11",
4
4
  "description": "Opra MongoDB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -25,13 +25,13 @@
25
25
  "clean:cover": "rimraf ../../coverage/mongodb"
26
26
  },
27
27
  "devDependencies": {
28
- "@faker-js/faker": "^8.3.1",
28
+ "@faker-js/faker": "^8.4.0",
29
29
  "mongodb": "^6.3.0",
30
- "ts-gems": "^3.1.0"
30
+ "ts-gems": "^3.1.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@opra/common": "^0.33.9",
34
- "@opra/core": "^0.33.9",
33
+ "@opra/common": "^0.33.11",
34
+ "@opra/core": "^0.33.11",
35
35
  "mongodb": ">=6.x.x"
36
36
  },
37
37
  "type": "module",