chore: upgrade mongoose to v8.10.x for security (#3868)

* chore: upgrade mongoose to v8.10.x for security

* chore: remove duplicate code

* fix: ts error
This commit is contained in:
Finley Ge
2025-02-26 18:32:19 +08:00
committed by GitHub
parent cf9c8e9f6a
commit 747bb303ec
7 changed files with 54 additions and 13 deletions

View File

@@ -18,10 +18,10 @@ export function getGFSCollection(bucket: `${BucketNameEnum}`) {
MongoDatasetFileSchema;
MongoChatFileSchema;
return connectionMongo.connection.db.collection(`${bucket}.files`);
return connectionMongo.connection.db!.collection(`${bucket}.files`);
}
export function getGridBucket(bucket: `${BucketNameEnum}`) {
return new connectionMongo.mongo.GridFSBucket(connectionMongo.connection.db, {
return new connectionMongo.mongo.GridFSBucket(connectionMongo.connection.db!, {
bucketName: bucket,
// @ts-ignore
readPreference: ReadPreference.SECONDARY_PREFERRED // Read from secondary node