support GridFS
This commit is contained in:
parent
ac2a0f46cd
commit
7e81e0db6a
3 changed files with 67 additions and 20 deletions
|
|
@ -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) &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue