@unchainedshop/mongodb 4.8.26 → 4.8.27

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.
@@ -0,0 +1,2 @@
1
+ export declare function assertDocumentDBCompatMode(): void;
2
+ export declare const isDocumentDBCompatModeEnabled: () => boolean;
@@ -0,0 +1,5 @@
1
+ export function assertDocumentDBCompatMode() {
2
+ if (isDocumentDBCompatModeEnabled())
3
+ throw new Error('Text search is not supported in DocumentDB Compatibility Mode');
4
+ }
5
+ export const isDocumentDBCompatModeEnabled = () => Boolean(process.env.UNCHAINED_DOCUMENTDB_COMPAT_MODE);
@@ -7,21 +7,21 @@ const extendSelectorWithLocale = (selector, locale) => {
7
7
  };
8
8
  export const findLocalizedText = async (collection, selector, locale) => {
9
9
  const exactTranslation = await collection.findOne(extendSelectorWithLocale(selector, locale), {
10
- sort: { updated: -1 },
10
+ sort: { updated: -1, _id: -1 },
11
11
  });
12
12
  if (exactTranslation) {
13
13
  return exactTranslation;
14
14
  }
15
15
  if (systemLocale.baseName !== locale.baseName) {
16
16
  const fallbackTranslation = await collection.findOne(extendSelectorWithLocale(selector, systemLocale), {
17
- sort: { updated: -1 },
17
+ sort: { updated: -1, _id: -1 },
18
18
  });
19
19
  if (fallbackTranslation) {
20
20
  return fallbackTranslation;
21
21
  }
22
22
  }
23
23
  const foundText = await collection.findOne(selector, {
24
- sort: { updated: -1 },
24
+ sort: { updated: -1, _id: -1 },
25
25
  });
26
26
  return foundText;
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/mongodb",
3
- "version": "4.8.26",
3
+ "version": "4.8.27",
4
4
  "description": "MongoDB database abstraction layer for the Unchained Engine",
5
5
  "main": "lib/mongodb-index.js",
6
6
  "types": "lib/mongodb-index.d.ts",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "homepage": "https://github.com/unchainedshop/unchained#readme",
35
35
  "dependencies": {
36
- "@unchainedshop/logger": "^4.8.12",
37
- "@unchainedshop/utils": "^4.8.12"
36
+ "@unchainedshop/logger": "^4.8.27",
37
+ "@unchainedshop/utils": "^4.8.27"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@mongodb-js/zstd": ">= 7 < 8",