@mikro-orm/mongodb 6.4.7-dev.1 → 7.0.0-dev.1
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/MongoConnection.d.ts +2 -3
- package/MongoConnection.js +13 -8
- package/MongoPlatform.d.ts +1 -0
- package/MongoPlatform.js +3 -0
- package/README.md +0 -2
- package/index.mjs +2 -0
- package/package.json +4 -4
package/MongoConnection.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MongoClient, type ClientSession, type Collection, type Db, type MongoClientOptions, type TransactionOptions } from 'mongodb';
|
|
2
|
-
import { Connection, type AnyEntity, type Configuration, type
|
|
2
|
+
import { Connection, type AnyEntity, type Configuration, type ConnectionOptions, type ConnectionType, type EntityData, type EntityName, type FilterQuery, type IsolationLevel, type QueryOrderMap, type QueryResult, type Transaction, type TransactionEventBroadcaster, type UpsertOptions, type UpsertManyOptions, type LoggingOptions } from '@mikro-orm/core';
|
|
3
3
|
export declare class MongoConnection extends Connection {
|
|
4
4
|
protected client: MongoClient;
|
|
5
5
|
protected db: Db;
|
|
@@ -19,8 +19,7 @@ export declare class MongoConnection extends Connection {
|
|
|
19
19
|
createCollection<T extends object>(name: EntityName<T>): Promise<Collection<T>>;
|
|
20
20
|
listCollections(): Promise<string[]>;
|
|
21
21
|
dropCollection(name: EntityName<AnyEntity>): Promise<boolean>;
|
|
22
|
-
|
|
23
|
-
getConnectionOptions(): MongoClientOptions & ConnectionConfig;
|
|
22
|
+
mapOptions(overrides: MongoClientOptions): MongoClientOptions;
|
|
24
23
|
getClientUrl(): string;
|
|
25
24
|
getDb(): Db;
|
|
26
25
|
execute(query: string): Promise<any>;
|
package/MongoConnection.js
CHANGED
|
@@ -20,14 +20,22 @@ class MongoConnection extends core_1.Connection {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
async connect() {
|
|
23
|
-
|
|
23
|
+
let driverOptions = this.options.driverOptions ?? this.config.get('driverOptions');
|
|
24
|
+
if (typeof driverOptions === 'function') {
|
|
25
|
+
driverOptions = await driverOptions();
|
|
26
|
+
}
|
|
24
27
|
if (driverOptions instanceof mongodb_1.MongoClient) {
|
|
25
28
|
this.logger.log('info', 'Reusing MongoClient provided via `driverOptions`');
|
|
26
29
|
this.client = driverOptions;
|
|
27
30
|
}
|
|
28
31
|
else {
|
|
29
|
-
this.client = new mongodb_1.MongoClient(this.config.getClientUrl(), this.
|
|
32
|
+
this.client = new mongodb_1.MongoClient(this.config.getClientUrl(), this.mapOptions(driverOptions));
|
|
30
33
|
await this.client.connect();
|
|
34
|
+
const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
|
|
35
|
+
/* istanbul ignore next */
|
|
36
|
+
this.client.on('connectionCreated', () => {
|
|
37
|
+
void onCreateConnection?.(this.client);
|
|
38
|
+
});
|
|
31
39
|
}
|
|
32
40
|
this.db = this.client.db(this.config.get('dbName'));
|
|
33
41
|
this.connected = true;
|
|
@@ -72,10 +80,7 @@ class MongoConnection extends core_1.Connection {
|
|
|
72
80
|
async dropCollection(name) {
|
|
73
81
|
return this.db.dropCollection(this.getCollectionName(name));
|
|
74
82
|
}
|
|
75
|
-
|
|
76
|
-
return 'mongodb://127.0.0.1:27017';
|
|
77
|
-
}
|
|
78
|
-
getConnectionOptions() {
|
|
83
|
+
mapOptions(overrides) {
|
|
79
84
|
const ret = {};
|
|
80
85
|
const pool = this.config.get('pool');
|
|
81
86
|
const username = this.config.get('user');
|
|
@@ -96,10 +101,10 @@ class MongoConnection extends core_1.Connection {
|
|
|
96
101
|
name: 'MikroORM',
|
|
97
102
|
version: core_1.Utils.getORMVersion(),
|
|
98
103
|
};
|
|
99
|
-
return core_1.Utils.mergeConfig(ret,
|
|
104
|
+
return core_1.Utils.mergeConfig(ret, overrides);
|
|
100
105
|
}
|
|
101
106
|
getClientUrl() {
|
|
102
|
-
const options = this.
|
|
107
|
+
const options = this.mapOptions(this.options.driverOptions ?? {});
|
|
103
108
|
const clientUrl = this.config.getClientUrl(true);
|
|
104
109
|
const match = clientUrl.match(/^(\w+):\/\/((.*@.+)|.+)$/);
|
|
105
110
|
return match ? `${match[1]}://${options.auth ? options.auth.username + ':*****@' : ''}${match[2]}` : clientUrl;
|
package/MongoPlatform.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export declare class MongoPlatform extends Platform {
|
|
|
27
27
|
shouldHaveColumn<T>(prop: EntityProperty<T>, populate: PopulateOptions<T>[], exclude?: string[]): boolean;
|
|
28
28
|
validateMetadata(meta: EntityMetadata): void;
|
|
29
29
|
isAllowedTopLevelOperator(operator: string): boolean;
|
|
30
|
+
getDefaultClientUrl(): string;
|
|
30
31
|
}
|
package/MongoPlatform.js
CHANGED
|
@@ -89,5 +89,8 @@ class MongoPlatform extends core_1.Platform {
|
|
|
89
89
|
isAllowedTopLevelOperator(operator) {
|
|
90
90
|
return ['$not', '$fulltext'].includes(operator);
|
|
91
91
|
}
|
|
92
|
+
getDefaultClientUrl() {
|
|
93
|
+
return 'mongodb://127.0.0.1:27017';
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
exports.MongoPlatform = MongoPlatform;
|
package/README.md
CHANGED
|
@@ -183,7 +183,6 @@ yarn add @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
|
|
|
183
183
|
yarn add @mikro-orm/core @mikro-orm/postgresql # for postgresql
|
|
184
184
|
yarn add @mikro-orm/core @mikro-orm/mssql # for mssql
|
|
185
185
|
yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
|
|
186
|
-
yarn add @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
|
|
187
186
|
yarn add @mikro-orm/core @mikro-orm/libsql # for libsql
|
|
188
187
|
```
|
|
189
188
|
|
|
@@ -196,7 +195,6 @@ npm i -s @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
|
|
|
196
195
|
npm i -s @mikro-orm/core @mikro-orm/postgresql # for postgresql
|
|
197
196
|
npm i -s @mikro-orm/core @mikro-orm/mssql # for mssql
|
|
198
197
|
npm i -s @mikro-orm/core @mikro-orm/sqlite # for sqlite
|
|
199
|
-
npm i -s @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
|
|
200
198
|
npm i -s @mikro-orm/core @mikro-orm/libsql # for libsql
|
|
201
199
|
```
|
|
202
200
|
|
package/index.mjs
CHANGED
|
@@ -146,6 +146,7 @@ export const QueryHelper = mod.QueryHelper;
|
|
|
146
146
|
export const QueryOperator = mod.QueryOperator;
|
|
147
147
|
export const QueryOrder = mod.QueryOrder;
|
|
148
148
|
export const QueryOrderNumeric = mod.QueryOrderNumeric;
|
|
149
|
+
export const Raw = mod.Raw;
|
|
149
150
|
export const RawQueryFragment = mod.RawQueryFragment;
|
|
150
151
|
export const ReadOnlyException = mod.ReadOnlyException;
|
|
151
152
|
export const Ref = mod.Ref;
|
|
@@ -193,6 +194,7 @@ export const equals = mod.equals;
|
|
|
193
194
|
export const getOnConflictFields = mod.getOnConflictFields;
|
|
194
195
|
export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
|
|
195
196
|
export const helper = mod.helper;
|
|
197
|
+
export const isRaw = mod.isRaw;
|
|
196
198
|
export const parseJsonSafe = mod.parseJsonSafe;
|
|
197
199
|
export const raw = mod.raw;
|
|
198
200
|
export const ref = mod.ref;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mongodb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-dev.1",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://mikro-orm.io",
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">= 22.11.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "yarn clean && yarn compile && yarn copy && yarn run -T gen-esm-wrapper index.js index.mjs",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"mongodb": "6.13.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@mikro-orm/core": "^6.4.
|
|
65
|
+
"@mikro-orm/core": "^6.4.5"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@mikro-orm/core": "
|
|
68
|
+
"@mikro-orm/core": "7.0.0-dev.1"
|
|
69
69
|
}
|
|
70
70
|
}
|