@opra/mongodb 0.26.3 → 0.26.4
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.
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoEntityService = void 0;
|
|
4
|
-
|
|
4
|
+
const core_1 = require("@opra/core");
|
|
5
|
+
class MongoEntityService extends core_1.ApiService {
|
|
5
6
|
constructor(arg0, arg1) {
|
|
7
|
+
super();
|
|
6
8
|
const options = typeof arg0 === 'object' ? arg0 : arg1;
|
|
7
9
|
if (typeof arg0 === 'string')
|
|
8
10
|
this._collectionName = arg0;
|
|
@@ -168,17 +170,9 @@ class MongoEntityService {
|
|
|
168
170
|
return this.forContext(context, db, session);
|
|
169
171
|
}
|
|
170
172
|
forContext(context, db, session) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
// Should reset session if db changed
|
|
175
|
-
if (db) {
|
|
176
|
-
instance.db = db;
|
|
177
|
-
instance.session = session;
|
|
178
|
-
}
|
|
179
|
-
if (session)
|
|
180
|
-
instance.session = session;
|
|
181
|
-
Object.setPrototypeOf(instance, this);
|
|
173
|
+
const instance = super.forContext(context);
|
|
174
|
+
instance.db = db || this.db;
|
|
175
|
+
instance.session = session || this.session;
|
|
182
176
|
return instance;
|
|
183
177
|
}
|
|
184
178
|
async _onError(error) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ApiService } from '@opra/core';
|
|
2
|
+
export class MongoEntityService extends ApiService {
|
|
2
3
|
constructor(arg0, arg1) {
|
|
4
|
+
super();
|
|
3
5
|
const options = typeof arg0 === 'object' ? arg0 : arg1;
|
|
4
6
|
if (typeof arg0 === 'string')
|
|
5
7
|
this._collectionName = arg0;
|
|
@@ -165,17 +167,9 @@ export class MongoEntityService {
|
|
|
165
167
|
return this.forContext(context, db, session);
|
|
166
168
|
}
|
|
167
169
|
forContext(context, db, session) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// Should reset session if db changed
|
|
172
|
-
if (db) {
|
|
173
|
-
instance.db = db;
|
|
174
|
-
instance.session = session;
|
|
175
|
-
}
|
|
176
|
-
if (session)
|
|
177
|
-
instance.session = session;
|
|
178
|
-
Object.setPrototypeOf(instance, this);
|
|
170
|
+
const instance = super.forContext(context);
|
|
171
|
+
instance.db = db || this.db;
|
|
172
|
+
instance.session = session || this.session;
|
|
179
173
|
return instance;
|
|
180
174
|
}
|
|
181
175
|
async _onError(error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/mongodb",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.4",
|
|
4
4
|
"description": "Opra MongoDB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"ts-gems": "^2.5.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@opra/common": "^0.26.
|
|
37
|
-
"@opra/core": "^0.26.
|
|
36
|
+
"@opra/common": "^0.26.4",
|
|
37
|
+
"@opra/core": "^0.26.4",
|
|
38
38
|
"mongodb": ">=6.x.x"
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import mongodb, { UpdateFilter } from 'mongodb';
|
|
2
2
|
import { StrictOmit } from 'ts-gems';
|
|
3
|
-
import { PartialOutput, RequestContext } from '@opra/core';
|
|
3
|
+
import { ApiService, PartialOutput, RequestContext } from '@opra/core';
|
|
4
4
|
export declare namespace MongoEntityService {
|
|
5
5
|
interface Options {
|
|
6
6
|
db?: mongodb.Db;
|
|
7
7
|
defaultLimit?: number;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export declare class MongoEntityService<T extends mongodb.Document> {
|
|
10
|
+
export declare class MongoEntityService<T extends mongodb.Document> extends ApiService {
|
|
11
11
|
protected _collectionName: string;
|
|
12
|
-
context: RequestContext;
|
|
13
12
|
defaultLimit: number;
|
|
14
13
|
db?: mongodb.Db;
|
|
15
14
|
session?: mongodb.ClientSession;
|
|
@@ -24,7 +23,7 @@ export declare class MongoEntityService<T extends mongodb.Document> {
|
|
|
24
23
|
updateOne(filter: mongodb.Filter<T>, doc: UpdateFilter<T> | Partial<T>, options?: mongodb.UpdateOptions): Promise<PartialOutput<T> | undefined>;
|
|
25
24
|
updateMany(filter: mongodb.Filter<T>, doc: UpdateFilter<T> | Partial<T>, options?: StrictOmit<mongodb.UpdateOptions, 'upsert'>): Promise<number>;
|
|
26
25
|
with(context: RequestContext, db?: mongodb.Db, session?: mongodb.ClientSession): MongoEntityService<T>;
|
|
27
|
-
forContext(context: RequestContext, db?: mongodb.Db, session?: mongodb.ClientSession):
|
|
26
|
+
forContext(context: RequestContext, db?: mongodb.Db, session?: mongodb.ClientSession): typeof this;
|
|
28
27
|
protected _onError(error: unknown): Promise<void>;
|
|
29
28
|
protected getDatabase(): mongodb.Db | Promise<mongodb.Db>;
|
|
30
29
|
protected getCollection(db: mongodb.Db): Promise<mongodb.Collection<T>>;
|