mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-03 00:25:57 +09:00
bcb04924ff
* Image for Web * Add comment * Make main to original
30 lines
825 B
TypeScript
30 lines
825 B
TypeScript
import * as mongo from 'mongodb';
|
|
import monkDb, { nativeDbConn } from '../db/mongodb';
|
|
|
|
const DriveFileWebpublic = monkDb.get<IDriveFileWebpublic>('driveFileWebpublics.files');
|
|
DriveFileWebpublic.createIndex('metadata.originalId', { sparse: true, unique: true });
|
|
export default DriveFileWebpublic;
|
|
|
|
export const DriveFileWebpublicChunk = monkDb.get('driveFileWebpublics.chunks');
|
|
|
|
export const getDriveFileWebpublicBucket = async (): Promise<mongo.GridFSBucket> => {
|
|
const db = await nativeDbConn();
|
|
const bucket = new mongo.GridFSBucket(db, {
|
|
bucketName: 'driveFileWebpublics'
|
|
});
|
|
return bucket;
|
|
};
|
|
|
|
export type IMetadata = {
|
|
originalId: mongo.ObjectID;
|
|
};
|
|
|
|
export type IDriveFileWebpublic = {
|
|
_id: mongo.ObjectID;
|
|
uploadDate: Date;
|
|
md5: string;
|
|
filename: string;
|
|
contentType: string;
|
|
metadata: IMetadata;
|
|
};
|