cgserver 12.2.5 → 12.2.6
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 +3 -0
- package/dist/lib/Framework/Database/Mongo/MongoBaseService.js +4 -0
- package/dist/lib/Framework/Database/Mongo/MongoManager.js +14 -0
- package/dist/types/Framework/Database/Mongo/MongoBaseService.d.ts +3 -0
- package/dist/types/Framework/Database/Mongo/MongoManager.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,10 @@ class MongoBaseService {
|
|
|
54
54
|
let rs = await this.mongoDb.findOne(this._table, where, property);
|
|
55
55
|
return rs.one;
|
|
56
56
|
}
|
|
57
|
+
async findOneAndUpdate(where = null, update, options) {
|
|
58
|
+
let rs = await this.mongoDb.findOneAndUpdate(this._table, where, update, options);
|
|
59
|
+
return rs;
|
|
60
|
+
}
|
|
57
61
|
async countDocuments(where = null, options) {
|
|
58
62
|
let rs = await this.mongoDb.countDocuments(this._table, where);
|
|
59
63
|
return rs.count;
|
|
@@ -698,6 +698,20 @@ class MongoExt {
|
|
|
698
698
|
this._mongocfg.debug && Log_1.gLog.info({ key: "bulkWrite", dt, arguments });
|
|
699
699
|
return bwr;
|
|
700
700
|
}
|
|
701
|
+
async findOneAndUpdate(collection, filter, update, options) {
|
|
702
|
+
let now = Date.now();
|
|
703
|
+
let dt = 0;
|
|
704
|
+
if (!this._mongoDb) {
|
|
705
|
+
dt = Date.now() - now;
|
|
706
|
+
this._mongocfg.debug && Log_1.gLog.info({ key: "findOneAndUpdate", dt, arguments });
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
let col = this._mongoDb.collection(collection);
|
|
710
|
+
let rs = await col.findOneAndUpdate(filter, update, options);
|
|
711
|
+
dt = Date.now() - now;
|
|
712
|
+
this._mongocfg.debug && Log_1.gLog.info({ key: "findOneAndUpdate", dt, arguments });
|
|
713
|
+
return rs;
|
|
714
|
+
}
|
|
701
715
|
}
|
|
702
716
|
exports.MongoExt = MongoExt;
|
|
703
717
|
exports.gMongoMgr = new MongoManager();
|
|
@@ -27,6 +27,9 @@ export declare class MongoBaseService<T extends MongoBaseModel> {
|
|
|
27
27
|
}, property?: {
|
|
28
28
|
[key: string]: any;
|
|
29
29
|
}): Promise<T>;
|
|
30
|
+
findOneAndUpdate(where: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}, update: any, options?: mongo.FindOneAndUpdateOptions): Promise<T>;
|
|
30
33
|
countDocuments(where?: {
|
|
31
34
|
[key: string]: any;
|
|
32
35
|
}, options?: mongo.CountDocumentsOptions): Promise<number>;
|
|
@@ -205,5 +205,6 @@ export declare class MongoExt {
|
|
|
205
205
|
*/
|
|
206
206
|
quickTransaction(cb: Function, options?: mongo.TransactionOptions): Promise<false | any>;
|
|
207
207
|
bulkWrite(collection: string, operations: mongo.AnyBulkWriteOperation<mongo.BSON.Document>[], options?: mongo.BulkWriteOptions): Promise<mongo.BulkWriteResult>;
|
|
208
|
+
findOneAndUpdate(collection: string, filter: any, update: any, options?: mongo.FindOneAndUpdateOptions): Promise<any>;
|
|
208
209
|
}
|
|
209
210
|
export declare let gMongoMgr: MongoManager;
|