summaryrefslogtreecommitdiff
path: root/src/api/models/drive-file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/models/drive-file.ts')
-rw-r--r--src/api/models/drive-file.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts
index 4c7204b1f4..8968d065cd 100644
--- a/src/api/models/drive-file.ts
+++ b/src/api/models/drive-file.ts
@@ -1,11 +1,22 @@
-import db from '../../db/mongodb';
+import * as mongodb from 'mongodb';
+import monkDb, { nativeDbConn } from '../../db/mongodb';
-const collection = db.get('drive_files');
+const collection = monkDb.get('drive_files.files');
-(collection as any).index('hash'); // fuck type definition
+(collection as any).createIndex('hash'); // fuck type definition
export default collection as any; // fuck type definition
+const getGridFSBucket = async (): Promise<mongodb.GridFSBucket> => {
+ const db = await nativeDbConn();
+ const bucket = new mongodb.GridFSBucket(db, {
+ bucketName: 'drive_files'
+ });
+ return bucket;
+};
+
+export { getGridFSBucket };
+
export function validateFileName(name: string): boolean {
return (
(name.trim().length > 0) &&