@unchainedshop/mongodb 5.0.0-alpha.1 → 5.0.0-alpha.3
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.
- package/README.md +2 -35
- package/lib/initDb.js +2 -2
- package/lib/mongodb-index.d.ts +0 -1
- package/lib/mongodb-index.js +0 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -53,13 +53,6 @@ await stopDb(db);
|
|
|
53
53
|
| `findLocalizedText` | Find localized text by locale with fallback |
|
|
54
54
|
| `insensitiveTrimmedRegexOperator` | Create case-insensitive trimmed regex for text search |
|
|
55
55
|
|
|
56
|
-
### DocumentDB Compatibility
|
|
57
|
-
|
|
58
|
-
| Export | Description |
|
|
59
|
-
|--------|-------------|
|
|
60
|
-
| `isDocumentDBCompatModeEnabled` | Check if AWS DocumentDB compatibility mode is enabled |
|
|
61
|
-
| `assertDocumentDBCompatMode` | Throw error if DocumentDB compat mode is enabled (for unsupported operations) |
|
|
62
|
-
|
|
63
56
|
### Re-exports
|
|
64
57
|
|
|
65
58
|
| Export | Description |
|
|
@@ -80,9 +73,7 @@ await stopDb(db);
|
|
|
80
73
|
|
|
81
74
|
## Environment Variables
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|----------|-------------|
|
|
85
|
-
| `UNCHAINED_DOCUMENTDB_COMPAT_MODE` | Enable AWS DocumentDB compatibility mode |
|
|
76
|
+
_No environment variables are required by this package._
|
|
86
77
|
|
|
87
78
|
## Best Practices
|
|
88
79
|
|
|
@@ -159,31 +150,7 @@ For full-text search, create compound text indexes:
|
|
|
159
150
|
}
|
|
160
151
|
```
|
|
161
152
|
|
|
162
|
-
**
|
|
163
|
-
|
|
164
|
-
### DocumentDB Compatibility
|
|
165
|
-
|
|
166
|
-
When running on AWS DocumentDB, some MongoDB features are not supported:
|
|
167
|
-
|
|
168
|
-
| Feature | Alternative |
|
|
169
|
-
|---------|-------------|
|
|
170
|
-
| Text indexes | Use application-level search or external search service |
|
|
171
|
-
| `$text` queries | Use regex queries (less performant) |
|
|
172
|
-
| Some aggregation operators | Check DocumentDB documentation |
|
|
173
|
-
|
|
174
|
-
Use the compatibility helpers:
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
import { isDocumentDBCompatModeEnabled, assertDocumentDBCompatMode } from '@unchainedshop/mongodb';
|
|
178
|
-
|
|
179
|
-
// Check before using unsupported features
|
|
180
|
-
if (!isDocumentDBCompatModeEnabled()) {
|
|
181
|
-
// Create text index
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Throw error if DocumentDB mode is enabled
|
|
185
|
-
assertDocumentDBCompatMode(); // Throws if in compat mode
|
|
186
|
-
```
|
|
153
|
+
**Note:** Text indexes are now created unconditionally on every collection. Supported runtimes: MongoDB 4.4+, AWS DocumentDB 5.0+ (text search added Feb 2024), AWS DocumentDB 8.0 (Text Index V2), FerretDB 2.x. AWS DocumentDB ≤4.0 and FerretDB 1.x are not supported.
|
|
187
154
|
|
|
188
155
|
## License
|
|
189
156
|
|
package/lib/initDb.js
CHANGED
|
@@ -43,9 +43,9 @@ export const startDb = async (options) => {
|
|
|
43
43
|
if (error.message?.includes('code "62"')) {
|
|
44
44
|
throw new Error(`MongoDB database files in .db are incompatible with the current MongoDB version. ` +
|
|
45
45
|
`This usually happens after a MongoDB upgrade. ` +
|
|
46
|
-
`To fix this, remove the .db directory: rm -rf ${process.cwd()}/.db`, { cause:
|
|
46
|
+
`To fix this, remove the .db directory: rm -rf ${process.cwd()}/.db`, { cause: e });
|
|
47
47
|
}
|
|
48
|
-
throw
|
|
48
|
+
throw e;
|
|
49
49
|
}
|
|
50
50
|
throw new Error("Can't connect to MongoDB: Could not start mongodb-memory-server and MONGO_URL env is not set");
|
|
51
51
|
};
|
package/lib/mongodb-index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export { findPreservingIds } from './find-preserving-ids.ts';
|
|
|
8
8
|
export { buildSortOptions } from './build-sort-option.ts';
|
|
9
9
|
export { findLocalizedText } from './find-localized-text.ts';
|
|
10
10
|
export { insensitiveTrimmedRegexOperator, escapeRegexString, } from './insensitive-trimmed-regex-operator.ts';
|
|
11
|
-
export * from './documentdb-compat-mode.ts';
|
|
12
11
|
export { mongodb };
|
|
13
12
|
export interface LogFields {
|
|
14
13
|
log: ({
|
package/lib/mongodb-index.js
CHANGED
|
@@ -7,5 +7,4 @@ export { findPreservingIds } from "./find-preserving-ids.js";
|
|
|
7
7
|
export { buildSortOptions } from "./build-sort-option.js";
|
|
8
8
|
export { findLocalizedText } from "./find-localized-text.js";
|
|
9
9
|
export { insensitiveTrimmedRegexOperator, escapeRegexString, } from "./insensitive-trimmed-regex-operator.js";
|
|
10
|
-
export * from "./documentdb-compat-mode.js";
|
|
11
10
|
export { mongodb };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/mongodb",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.3",
|
|
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,6 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@unchainedshop/logger": "^5.0.0-alpha.1",
|
|
36
37
|
"@unchainedshop/utils": "^5.0.0-alpha.1"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@types/node": "^
|
|
56
|
+
"@types/node": "^26.2.0",
|
|
56
57
|
"typescript": "^5.8.3"
|
|
57
58
|
}
|
|
58
59
|
}
|