@resolveio/server-lib 9.7.16 → 9.7.17
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/index.d.ts +3 -2
- package/index.js +1 -4
- package/index.js.map +1 -1
- package/managers/mongo.manager.d.ts +38 -56
- package/managers/mongo.manager.js +41 -41
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +82 -6
- package/managers/monitor.manager.js.map +1 -1
- package/methods/accounts.js.map +1 -1
- package/package.json +3 -3
- package/server-app.js +1 -1
- package/server-app.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Db, MongoClient } from 'mongodb';
|
|
1
2
|
import { MongoManager } from './managers/mongo.manager';
|
|
2
3
|
import ResolveIOMainServer from './server-app';
|
|
3
4
|
export declare class ResolveIOServer {
|
|
@@ -16,8 +17,8 @@ export declare class ResolveIOServer {
|
|
|
16
17
|
static connectAndRun(): Promise<unknown>;
|
|
17
18
|
static getClientName(): string;
|
|
18
19
|
static getMainServer(): ResolveIOMainServer;
|
|
19
|
-
static getMongoConnection():
|
|
20
|
-
static getMainDB():
|
|
20
|
+
static getMongoConnection(): MongoClient;
|
|
21
|
+
static getMainDB(): Db;
|
|
21
22
|
static getMongoManager(): MongoManager;
|
|
22
23
|
}
|
|
23
24
|
export * from './public_api';
|
package/index.js
CHANGED
|
@@ -64,10 +64,7 @@ var ResolveIOServer = /** @class */ (function () {
|
|
|
64
64
|
ResolveIOServer.connectAndRun = function () {
|
|
65
65
|
var _this = this;
|
|
66
66
|
return new Promise(function (resolve, reject) {
|
|
67
|
-
mongodb_1.MongoClient.connect(ResolveIOServer._serverConfig['MONGO_URL']
|
|
68
|
-
useNewUrlParser: true,
|
|
69
|
-
useUnifiedTopology: ResolveIOServer._serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? true : false
|
|
70
|
-
}).then(function (dbConnection) {
|
|
67
|
+
mongodb_1.MongoClient.connect(ResolveIOServer._serverConfig['MONGO_URL']).then(function (dbConnection) {
|
|
71
68
|
ResolveIOServer._mongoConnection = dbConnection;
|
|
72
69
|
ResolveIOServer._mainDB = dbConnection.db(ResolveIOServer._serverConfig['DATABASE']);
|
|
73
70
|
ResolveIOServer._mongoManager = new mongo_manager_1.MongoManager();
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA0C;AAC1C,0DAAwD;AAGxD;IAaC,yBAAY,UAAU,EAAE,YAAY,EAAE,YAAsB,EAAE,MAAc,EAAE,SAAS,EAAE,OAAc,EAAE,eAAuB;QAAvC,wBAAA,EAAA,cAAc;QAAE,gCAAA,EAAA,uBAAuB;QAC/H,eAAe,CAAC,aAAa,GAAG,UAAU,CAAC;QAC3C,eAAe,CAAC,aAAa,GAAG,YAAY,CAAC;QAC7C,eAAe,CAAC,aAAa,GAAG,YAAY,CAAC;QAC7C,eAAe,CAAC,OAAO,GAAG,MAAM,CAAC;QACjC,eAAe,CAAC,UAAU,GAAG,SAAS,CAAC;QACvC,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAC;QACnC,eAAe,CAAC,gBAAgB,GAAG,eAAe,CAAC;IACpD,CAAC;IAEa,6BAAa,GAA3B;QAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["import { Db, MongoClient } from 'mongodb';\nimport { MongoManager } from './managers/mongo.manager';\nimport ResolveIOMainServer from './server-app';\n\nexport class ResolveIOServer {\n\tprivate static _monitorAgent = null;\n\tprivate static _serverConfig = null;\n\tprivate static _clientRoutes = [];\n\tprivate static _mongoConnection: MongoClient = null;\n\tprivate static _mainDB: Db = null;\n\tprivate static _mainServer: ResolveIOMainServer = null;\n\tprivate static _mongoManager: MongoManager = null;\n\tprivate static _client = '';\n\tprivate static _clientDir = '';\n\tprivate static _sesMail = true;\n\tprivate static _standardProgram = false;\n\n\tconstructor(monitoring, serverConfig, clientRoutes: string[], client: string, clientDir, sesMail = true, standardProgram = false) {\n\t\tResolveIOServer._monitorAgent = monitoring;\n\t\tResolveIOServer._serverConfig = serverConfig;\n\t\tResolveIOServer._clientRoutes = clientRoutes;\n\t\tResolveIOServer._client = client;\n\t\tResolveIOServer._clientDir = clientDir;\n\t\tResolveIOServer._sesMail = sesMail;\n\t\tResolveIOServer._standardProgram = standardProgram;\n\t}\n\n\tpublic static connectAndRun() {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tMongoClient.connect(ResolveIOServer._serverConfig['MONGO_URL']).then(dbConnection => {\n\t\t\t\tResolveIOServer._mongoConnection = dbConnection;\n\t\t\t\tResolveIOServer._mainDB = dbConnection.db(ResolveIOServer._serverConfig['DATABASE']);\n\t\t\t\tResolveIOServer._mongoManager = new MongoManager();\n\t\t\t\t\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tlet serverApp = (await import('./server-app')).default;\n\t\t\t\t\tResolveIOServer._mainServer = new serverApp(this, ResolveIOServer._monitorAgent, ResolveIOServer._serverConfig, ResolveIOServer._clientRoutes, this._clientDir, this._sesMail, this._standardProgram);\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}, 1);\n\t\t\t}, err => {\n\t\t\t\tconsole.error(new Date(), 'MONGO CLIENT CONNECT FAILED', JSON.stringify(err, null, 2));\n\t\t\t\treject();\n\t\t\t\tprocess.exit(1);\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic static getClientName() {\n\t\treturn this._client;\n\t}\n\n\tpublic static getMainServer() {\n\t\treturn ResolveIOServer._mainServer;\n\t}\n\n\tpublic static getMongoConnection() {\n\t\treturn ResolveIOServer._mongoConnection;\n\t}\n\n\tpublic static getMainDB() {\n\t\treturn ResolveIOServer._mainDB;\n\t}\n\n\tpublic static getMongoManager() {\n\t\treturn ResolveIOServer._mongoManager;\n\t}\n}\n\nexport * from './public_api';"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AggregateOptions, BulkWriteOptions, ChangeStreamOptions, ClientSession, CommandOperationOptions, CountDocumentsOptions, CreateIndexesOptions, CursorStreamOptions, DeleteOptions, Filter, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, FindOptions, IndexDescription, InsertOneOptions, ListIndexesOptions, RenameOptions, ReplaceOptions, UpdateFilter, UpdateOptions } from 'mongodb';
|
|
2
3
|
import { LookupTables } from '../models/report-builder.model';
|
|
3
4
|
import { UserModel } from '../models/user.model';
|
|
4
5
|
interface MongoQueueModel {
|
|
@@ -50,73 +51,54 @@ export declare class Collection<T> {
|
|
|
50
51
|
createLogs: boolean;
|
|
51
52
|
useRB: boolean;
|
|
52
53
|
constructor(collectionName: string, schema: object, useReportBuilder: any, reportBuilderLookupTables: LookupTables[], timestamps: any, createLogs: any, checkSchema: any);
|
|
53
|
-
aggregate(pipeline: object[], options?:
|
|
54
|
-
aggregateCount(pipeline: object[], options?:
|
|
55
|
-
aggregateCursor(pipeline: object[], options?:
|
|
56
|
-
aggregateStream(pipeline: object[], options?:
|
|
57
|
-
countDocuments(filter?:
|
|
58
|
-
create(f_docs: T | T[], options?:
|
|
59
|
-
createIndex(fieldOrSpec: any, options?:
|
|
60
|
-
createIndexes(indexSpecs:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
deleteMany(filter?: FilterQuery<T>, options?: CommonOptions, bypassLogs?: boolean): Promise<unknown>;
|
|
64
|
-
deleteOne(filter?: FilterQuery<T>, options?: CommonOptions & {
|
|
54
|
+
aggregate(pipeline: object[], options?: AggregateOptions, allowLogs?: boolean): Promise<any[]>;
|
|
55
|
+
aggregateCount(pipeline: object[], options?: AggregateOptions): Promise<number>;
|
|
56
|
+
aggregateCursor(pipeline: object[], options?: AggregateOptions): import("mongodb").AggregationCursor<import("bson").Document>;
|
|
57
|
+
aggregateStream(pipeline: object[], options?: AggregateOptions): import("stream").Readable;
|
|
58
|
+
countDocuments(filter?: Filter<T>, options?: CountDocumentsOptions): Promise<number>;
|
|
59
|
+
create(f_docs: T | T[], options?: InsertOneOptions | BulkWriteOptions): Promise<T | T[]>;
|
|
60
|
+
createIndex(fieldOrSpec: any, options?: CreateIndexesOptions): Promise<string>;
|
|
61
|
+
createIndexes(indexSpecs: IndexDescription[], options?: CreateIndexesOptions): Promise<string[]>;
|
|
62
|
+
deleteMany(filter?: Filter<T>, options?: DeleteOptions, bypassLogs?: boolean): Promise<unknown>;
|
|
63
|
+
deleteOne(filter?: Filter<T>, options?: FindOneAndDeleteOptions & {
|
|
65
64
|
bypassDocumentValidation?: boolean;
|
|
66
65
|
}, bypassLogs?: boolean): Promise<unknown>;
|
|
67
|
-
distinct(key: string, filter?:
|
|
68
|
-
drop(options?:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
findCount(filter?: FilterQuery<T>, options?: FindOneOptions<T>, bypassLogs?: boolean): any;
|
|
81
|
-
findCursor(filter?: FilterQuery<T>, options?: FindOneOptions<T>): any;
|
|
82
|
-
findStream(filter?: FilterQuery<T>, options?: FindOneOptions<T>, streamOptions?: any): any;
|
|
83
|
-
findOne(filter?: FilterQuery<T>, options?: FindOneOptions<T>, bypassLogs?: boolean): Promise<T>;
|
|
84
|
-
findOneAndDelete(filter?: FilterQuery<T>, options?: FindOneAndDeleteOption<T>, bypassLogs?: boolean): Promise<T>;
|
|
85
|
-
findOneAndReplace(filter: FilterQuery<T>, replacement: T, options?: FindOneAndReplaceOption<T>, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<T>;
|
|
86
|
-
findOneAndUpdate(filter: FilterQuery<T>, update: any, options?: FindOneAndUpdateOption<T>, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<T>;
|
|
66
|
+
distinct(key: string, filter?: Filter<T>, options?: CommandOperationOptions): Promise<T[]>;
|
|
67
|
+
drop(options?: CommandOperationOptions): Promise<boolean>;
|
|
68
|
+
dropIndex(indexName: string, options?: CommandOperationOptions): Promise<import("bson").Document>;
|
|
69
|
+
dropIndexes(options?: CommandOperationOptions): Promise<import("bson").Document>;
|
|
70
|
+
find(filter?: Filter<T>, options?: FindOptions<T>, bypassLogs?: boolean): Promise<T[]>;
|
|
71
|
+
findById(id: string, options?: FindOptions<T>): Promise<T>;
|
|
72
|
+
findCount(filter?: Filter<T>, options?: FindOptions<T>, bypassLogs?: boolean): Promise<Number>;
|
|
73
|
+
findCursor(filter?: Filter<T>, options?: FindOptions<T>): import("mongodb").FindCursor<import("bson").Document>;
|
|
74
|
+
findStream(filter?: Filter<T>, options?: FindOptions<T>, streamOptions?: CursorStreamOptions): import("stream").Readable;
|
|
75
|
+
findOne(filter?: Filter<T>, options?: FindOptions<T>, bypassLogs?: boolean): Promise<T>;
|
|
76
|
+
findOneAndDelete(filter?: Filter<T>, options?: FindOneAndDeleteOptions, bypassLogs?: boolean): Promise<T>;
|
|
77
|
+
findOneAndReplace(filter: Filter<T>, replacement: T, options?: FindOneAndReplaceOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<T>;
|
|
78
|
+
findOneAndUpdate(filter: Filter<T>, update: any, options?: FindOneAndUpdateOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<T>;
|
|
87
79
|
indexes(options?: {
|
|
88
80
|
session: ClientSession;
|
|
89
|
-
}):
|
|
81
|
+
}): Promise<import("bson").Document[]>;
|
|
90
82
|
indexExists(indexes: string | string[], options?: {
|
|
91
83
|
session: ClientSession;
|
|
92
|
-
}):
|
|
93
|
-
insertMany(docs: T[], options?:
|
|
94
|
-
insertOne(doc: T, options?:
|
|
95
|
-
listIndexes(options?:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
session?: ClientSession;
|
|
99
|
-
}): any;
|
|
100
|
-
reIndex(options?: {
|
|
101
|
-
session: ClientSession;
|
|
102
|
-
}): any;
|
|
103
|
-
rename(newName: string, options?: {
|
|
104
|
-
dropTarget?: boolean;
|
|
105
|
-
session?: ClientSession;
|
|
106
|
-
}): any;
|
|
107
|
-
replaceOne(filter: FilterQuery<T>, replacement: T, options?: ReplaceOneOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean, doc?: T): Promise<number>;
|
|
84
|
+
}): Promise<boolean>;
|
|
85
|
+
insertMany(docs: T[], options?: BulkWriteOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<T[]>;
|
|
86
|
+
insertOne(doc: T, options?: InsertOneOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<T>;
|
|
87
|
+
listIndexes(options?: ListIndexesOptions): import("mongodb").ListIndexesCursor;
|
|
88
|
+
rename(newName: string, options?: RenameOptions): Promise<import("mongodb").Collection<import("bson").Document>>;
|
|
89
|
+
replaceOne(filter: Filter<T>, replacement: T, options?: ReplaceOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean, doc?: T): Promise<number>;
|
|
108
90
|
stats(options?: {
|
|
109
91
|
scale: number;
|
|
110
92
|
session?: ClientSession;
|
|
111
|
-
}):
|
|
112
|
-
updateMany(filter:
|
|
113
|
-
updateOne(filter:
|
|
93
|
+
}): Promise<import("mongodb").CollStats>;
|
|
94
|
+
updateMany(filter: Filter<T>, update: UpdateFilter<T>, options?: UpdateOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean, bypassVersions?: boolean): Promise<number>;
|
|
95
|
+
updateOne(filter: Filter<T>, update: UpdateFilter<T>, options?: UpdateOptions, bypassLogs?: boolean, bypassCheckSchema?: boolean): Promise<number>;
|
|
114
96
|
watchCollection(pipeline?: any[], options?: ChangeStreamOptions & {
|
|
115
97
|
session?: ClientSession;
|
|
116
|
-
}):
|
|
98
|
+
}): import("mongodb").ChangeStream<import("bson").Document>;
|
|
117
99
|
watchCollectionWithAggregate(pipeline?: any[], options?: ChangeStreamOptions & {
|
|
118
100
|
session?: ClientSession;
|
|
119
|
-
}):
|
|
101
|
+
}): import("mongodb").ChangeStream<import("bson").Document>;
|
|
120
102
|
}
|
|
121
103
|
export declare class UserCollection<T> extends Collection<T> {
|
|
122
104
|
authenticateStrategy(): (username: any, password: any, cb: any) => Promise<void>;
|
|
@@ -131,5 +113,5 @@ export declare class UserCollection<T> extends Collection<T> {
|
|
|
131
113
|
register(user: any, password: any): Promise<unknown>;
|
|
132
114
|
resetAttempts(user: UserModel): Promise<number>;
|
|
133
115
|
}
|
|
134
|
-
export declare function objectIdHexString():
|
|
116
|
+
export declare function objectIdHexString(): string;
|
|
135
117
|
export {};
|
|
@@ -430,13 +430,13 @@ var Collection = /** @class */ (function () {
|
|
|
430
430
|
_a.label = 2;
|
|
431
431
|
case 2:
|
|
432
432
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteMany(filter, options).then(function (res) {
|
|
433
|
-
if (res.
|
|
433
|
+
if (res.acknowledged) {
|
|
434
434
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
435
435
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'delete');
|
|
436
436
|
resolve(res.deletedCount);
|
|
437
437
|
}
|
|
438
438
|
else {
|
|
439
|
-
reject(res.
|
|
439
|
+
reject(res.acknowledged);
|
|
440
440
|
}
|
|
441
441
|
}, function (err) { return reject(err); });
|
|
442
442
|
return [2 /*return*/];
|
|
@@ -489,13 +489,13 @@ var Collection = /** @class */ (function () {
|
|
|
489
489
|
}
|
|
490
490
|
else {
|
|
491
491
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteOne(filter, options).then(function (res) {
|
|
492
|
-
if (res.
|
|
492
|
+
if (res.acknowledged) {
|
|
493
493
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
494
494
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'delete');
|
|
495
495
|
resolve(res.deletedCount);
|
|
496
496
|
}
|
|
497
497
|
else {
|
|
498
|
-
reject(res.
|
|
498
|
+
reject(res.acknowledged);
|
|
499
499
|
}
|
|
500
500
|
}, function (err) { return reject(err); });
|
|
501
501
|
}
|
|
@@ -578,7 +578,10 @@ var Collection = /** @class */ (function () {
|
|
|
578
578
|
}); });
|
|
579
579
|
};
|
|
580
580
|
Collection.prototype.findById = function (id, options) {
|
|
581
|
-
|
|
581
|
+
var _this = this;
|
|
582
|
+
return new Promise(function (resolve, reject) {
|
|
583
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).findOne({ _id: id }, options).then(function (res) { return resolve(res); }, function (err) { return reject(err); });
|
|
584
|
+
});
|
|
582
585
|
};
|
|
583
586
|
Collection.prototype.findCount = function (filter, options, bypassLogs) {
|
|
584
587
|
if (filter === void 0) { filter = {}; }
|
|
@@ -922,13 +925,13 @@ var Collection = /** @class */ (function () {
|
|
|
922
925
|
}
|
|
923
926
|
if (validDocs.length) {
|
|
924
927
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).insertMany(validDocs, options).then(function (res) {
|
|
925
|
-
if (res.
|
|
928
|
+
if (res.acknowledged) {
|
|
926
929
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
927
930
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'insert');
|
|
928
931
|
resolve(validDocs);
|
|
929
932
|
}
|
|
930
933
|
else {
|
|
931
|
-
reject(res.
|
|
934
|
+
reject(res.acknowledged);
|
|
932
935
|
}
|
|
933
936
|
}, function (err) {
|
|
934
937
|
reject(err);
|
|
@@ -982,13 +985,13 @@ var Collection = /** @class */ (function () {
|
|
|
982
985
|
doc['__v'] = 0;
|
|
983
986
|
}
|
|
984
987
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).insertOne(doc, options).then(function (res) {
|
|
985
|
-
if (res.
|
|
988
|
+
if (res.acknowledged) {
|
|
986
989
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
987
990
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'insert');
|
|
988
991
|
resolve(doc);
|
|
989
992
|
}
|
|
990
993
|
else {
|
|
991
|
-
reject(res.
|
|
994
|
+
reject(res.acknowledged);
|
|
992
995
|
}
|
|
993
996
|
}, function (err) {
|
|
994
997
|
reject(err);
|
|
@@ -1000,9 +1003,6 @@ var Collection = /** @class */ (function () {
|
|
|
1000
1003
|
Collection.prototype.listIndexes = function (options) {
|
|
1001
1004
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).listIndexes(options);
|
|
1002
1005
|
};
|
|
1003
|
-
Collection.prototype.reIndex = function (options) {
|
|
1004
|
-
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).reIndex(options);
|
|
1005
|
-
};
|
|
1006
1006
|
Collection.prototype.rename = function (newName, options) {
|
|
1007
1007
|
return index_1.ResolveIOServer.getMainDB().collection(this.collectionName).rename(newName, options);
|
|
1008
1008
|
};
|
|
@@ -1046,7 +1046,7 @@ var Collection = /** @class */ (function () {
|
|
|
1046
1046
|
replacement['__v'] += 1;
|
|
1047
1047
|
versionDoc = common_1.deepCopy(doc);
|
|
1048
1048
|
versionDoc['_id'] = { _id: doc['_id'], __v: doc['__v'] };
|
|
1049
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc['_id'], __v: doc['__v'] } }, versionDoc,
|
|
1049
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc['_id'], __v: doc['__v'] } }, versionDoc, options);
|
|
1050
1050
|
if (doc['__v'] >= 4) {
|
|
1051
1051
|
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({
|
|
1052
1052
|
_id: {
|
|
@@ -1070,13 +1070,13 @@ var Collection = /** @class */ (function () {
|
|
|
1070
1070
|
});
|
|
1071
1071
|
}
|
|
1072
1072
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1073
|
-
if (res.
|
|
1073
|
+
if (res.acknowledged) {
|
|
1074
1074
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1075
1075
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1076
|
-
resolve(res.
|
|
1076
|
+
resolve(res.modifiedCount);
|
|
1077
1077
|
}
|
|
1078
1078
|
else {
|
|
1079
|
-
reject(res.
|
|
1079
|
+
reject(res.acknowledged);
|
|
1080
1080
|
}
|
|
1081
1081
|
}, function (err) {
|
|
1082
1082
|
reject(err);
|
|
@@ -1113,13 +1113,13 @@ var Collection = /** @class */ (function () {
|
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, updatedDoc, options).then(function (res) {
|
|
1116
|
-
if (res.
|
|
1116
|
+
if (res.acknowledged) {
|
|
1117
1117
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1118
1118
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1119
|
-
resolve(res.
|
|
1119
|
+
resolve(res.modifiedCount);
|
|
1120
1120
|
}
|
|
1121
1121
|
else {
|
|
1122
|
-
reject(res.
|
|
1122
|
+
reject(res.acknowledged);
|
|
1123
1123
|
}
|
|
1124
1124
|
}, function (err) {
|
|
1125
1125
|
reject(err);
|
|
@@ -1154,13 +1154,13 @@ var Collection = /** @class */ (function () {
|
|
|
1154
1154
|
});
|
|
1155
1155
|
}
|
|
1156
1156
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1157
|
-
if (res.
|
|
1157
|
+
if (res.acknowledged) {
|
|
1158
1158
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1159
1159
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1160
|
-
resolve(res.
|
|
1160
|
+
resolve(res.modifiedCount);
|
|
1161
1161
|
}
|
|
1162
1162
|
else {
|
|
1163
|
-
reject(res.
|
|
1163
|
+
reject(res.acknowledged);
|
|
1164
1164
|
}
|
|
1165
1165
|
}, function (err) {
|
|
1166
1166
|
reject(err);
|
|
@@ -1183,10 +1183,10 @@ var Collection = /** @class */ (function () {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
if (this.createLogs && !bypassLogs) {
|
|
1185
1185
|
if (!options) {
|
|
1186
|
-
options = {
|
|
1186
|
+
options = { returnDocument: 'before' };
|
|
1187
1187
|
}
|
|
1188
1188
|
else {
|
|
1189
|
-
options.
|
|
1189
|
+
options.returnDocument = 'before';
|
|
1190
1190
|
}
|
|
1191
1191
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndReplace(filter, replacement, options).then(function (res) {
|
|
1192
1192
|
var doc = res.value;
|
|
@@ -1225,13 +1225,13 @@ var Collection = /** @class */ (function () {
|
|
|
1225
1225
|
}
|
|
1226
1226
|
else {
|
|
1227
1227
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1228
|
-
if (res.
|
|
1228
|
+
if (res.acknowledged) {
|
|
1229
1229
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1230
1230
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1231
|
-
resolve(res.
|
|
1231
|
+
resolve(res.modifiedCount);
|
|
1232
1232
|
}
|
|
1233
1233
|
else {
|
|
1234
|
-
reject(res.
|
|
1234
|
+
reject(res.acknowledged);
|
|
1235
1235
|
}
|
|
1236
1236
|
}, function (err) {
|
|
1237
1237
|
reject(err);
|
|
@@ -1321,13 +1321,13 @@ var Collection = /** @class */ (function () {
|
|
|
1321
1321
|
_a.label = 2;
|
|
1322
1322
|
case 2:
|
|
1323
1323
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateMany(filter, update, options).then(function (res) {
|
|
1324
|
-
if (res.
|
|
1324
|
+
if (res.acknowledged) {
|
|
1325
1325
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1326
1326
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1327
|
-
resolve(res.
|
|
1327
|
+
resolve(res.modifiedCount);
|
|
1328
1328
|
}
|
|
1329
1329
|
else {
|
|
1330
|
-
reject(res.
|
|
1330
|
+
reject(res.acknowledged);
|
|
1331
1331
|
}
|
|
1332
1332
|
}, function (err) { return reject(err); });
|
|
1333
1333
|
return [2 /*return*/];
|
|
@@ -1403,13 +1403,13 @@ var Collection = /** @class */ (function () {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
}
|
|
1405
1405
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1406
|
-
if (res.
|
|
1406
|
+
if (res.acknowledged) {
|
|
1407
1407
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1408
1408
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1409
|
-
resolve(res.
|
|
1409
|
+
resolve(res.modifiedCount);
|
|
1410
1410
|
}
|
|
1411
1411
|
else {
|
|
1412
|
-
reject(res.
|
|
1412
|
+
reject(res.acknowledged);
|
|
1413
1413
|
}
|
|
1414
1414
|
}, function (err) { return reject(err); });
|
|
1415
1415
|
}
|
|
@@ -1452,13 +1452,13 @@ var Collection = /** @class */ (function () {
|
|
|
1452
1452
|
});
|
|
1453
1453
|
}
|
|
1454
1454
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1455
|
-
if (res.
|
|
1455
|
+
if (res.acknowledged) {
|
|
1456
1456
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1457
1457
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1458
|
-
resolve(res.
|
|
1458
|
+
resolve(res.modifiedCount);
|
|
1459
1459
|
}
|
|
1460
1460
|
else {
|
|
1461
|
-
reject(res.
|
|
1461
|
+
reject(res.acknowledged);
|
|
1462
1462
|
}
|
|
1463
1463
|
}, function (err) { return reject(err); });
|
|
1464
1464
|
}
|
|
@@ -1492,10 +1492,10 @@ var Collection = /** @class */ (function () {
|
|
|
1492
1492
|
}
|
|
1493
1493
|
if (this.createLogs && !bypassLogs) {
|
|
1494
1494
|
if (!options) {
|
|
1495
|
-
options = {
|
|
1495
|
+
options = { returnDocument: 'before' };
|
|
1496
1496
|
}
|
|
1497
1497
|
else {
|
|
1498
|
-
options.
|
|
1498
|
+
options.returnDocument = 'before';
|
|
1499
1499
|
}
|
|
1500
1500
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndUpdate(filter, update, options).then(function (res) {
|
|
1501
1501
|
var doc = res.value;
|
|
@@ -1538,13 +1538,13 @@ var Collection = /** @class */ (function () {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
else {
|
|
1540
1540
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1541
|
-
if (res.
|
|
1541
|
+
if (res.acknowledged) {
|
|
1542
1542
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1543
1543
|
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().invalidatePubsCache(_this.collectionName, 'update');
|
|
1544
|
-
resolve(res.
|
|
1544
|
+
resolve(res.modifiedCount);
|
|
1545
1545
|
}
|
|
1546
1546
|
else {
|
|
1547
|
-
reject(res.
|
|
1547
|
+
reject(res.acknowledged);
|
|
1548
1548
|
}
|
|
1549
1549
|
}, function (err) { return reject(err); });
|
|
1550
1550
|
}
|