summaryrefslogtreecommitdiff
path: root/src/api/models
diff options
context:
space:
mode:
authorotofune <otofune@gmail.com>2017-11-06 14:37:00 +0900
committerotofune <otofune@gmail.com>2017-11-06 14:37:24 +0900
commit7e81e0db6ac1289ae9504f7e3da5db6e56f41a51 (patch)
tree8f43f66a74ee6f9114f89b48262eeef5084fbaaf /src/api/models
parentupdate @prezzemolo/rap to 0.1.2 (diff)
downloadsharkey-7e81e0db6ac1289ae9504f7e3da5db6e56f41a51.tar.gz
sharkey-7e81e0db6ac1289ae9504f7e3da5db6e56f41a51.tar.bz2
sharkey-7e81e0db6ac1289ae9504f7e3da5db6e56f41a51.zip
support GridFS
Diffstat (limited to 'src/api/models')
-rw-r--r--src/api/models/drive-file.ts15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts
index 8d158cf563..79a87f6572 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).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) &&