From a452f12654762ef9679b3fb8798776571b69c054 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Mon, 18 Dec 2023 19:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=9E=90db=20find=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/setMongodb.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/setMongodb.ts b/src/setMongodb.ts index 8ab7e8b..d9e4d43 100644 --- a/src/setMongodb.ts +++ b/src/setMongodb.ts @@ -2,6 +2,7 @@ import { Collection, CreateIndexesOptions, Db, + FindCursor, IndexDescription, IndexSpecification, MongoClient, @@ -18,6 +19,7 @@ import {HuoDongFun} from './public/huodongfun'; import {zbsGroup} from './api_s2c/hbzb/zbs/fun'; import {clusterRunOnce} from './clusterUtils'; import { PublicShared } from './shared/public/public'; +import { addGameLog } from './gameLog'; const indexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[] }> = { item: [ @@ -626,4 +628,22 @@ export class _mongodb { indexInformation(name) { return this.db.indexInformation(name) } +} + +//@ts-ignore +FindCursor.prototype._toArray = FindCursor.prototype.toArray; +//@ts-ignore +FindCursor.prototype.toArray = async function(){ + let rss = await this._toArray(); + + //如果返回的数据超过50条 + if(rss.length>50){ + addGameLog("system","findCount",null,{ + collection: this.namespace.collection, + db:this.namespace.db, + filter: this.filter, + count:rss.length + }) + } + return rss; } \ No newline at end of file