mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-28 00:33:08 +02:00
108dcb3e61
これらの処理はパフォーマンス的に現実的でないし、すべてのモデルの関係を把握している必要があり保守が困難 論理削除でなんとかする
29 lines
825 B
TypeScript
29 lines
825 B
TypeScript
import * as mongo from 'mongodb';
|
|
import monkDb, { nativeDbConn } from '../db/mongodb';
|
|
|
|
const DriveFileThumbnail = monkDb.get<IDriveFileThumbnail>('driveFileThumbnails.files');
|
|
DriveFileThumbnail.createIndex('metadata.originalId', { sparse: true, unique: true });
|
|
export default DriveFileThumbnail;
|
|
|
|
export const DriveFileThumbnailChunk = monkDb.get('driveFileThumbnails.chunks');
|
|
|
|
export const getDriveFileThumbnailBucket = async (): Promise<mongo.GridFSBucket> => {
|
|
const db = await nativeDbConn();
|
|
const bucket = new mongo.GridFSBucket(db, {
|
|
bucketName: 'driveFileThumbnails'
|
|
});
|
|
return bucket;
|
|
};
|
|
|
|
export type IMetadata = {
|
|
originalId: mongo.ObjectID;
|
|
};
|
|
|
|
export type IDriveFileThumbnail = {
|
|
_id: mongo.ObjectID;
|
|
uploadDate: Date;
|
|
md5: string;
|
|
filename: string;
|
|
contentType: string;
|
|
metadata: IMetadata;
|
|
};
|