refactor: Convert trash to raw (#28939)
parent
ae520dd29a
commit
e480563602
@ -1,17 +1,5 @@ |
||||
import { Mongo } from 'meteor/mongo'; |
||||
import type { Collection } from 'mongodb'; |
||||
import { TrashRaw } from '../models/raw/Trash'; |
||||
import { db } from './utils'; |
||||
|
||||
import { SystemLogger } from '../lib/logger/system'; |
||||
|
||||
// TODO need to improve how other files imports this
|
||||
export const trash = new Mongo.Collection('rocketchat__trash'); |
||||
try { |
||||
trash._ensureIndex({ __collection__: 1 }); |
||||
trash._ensureIndex({ _deletedAt: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 30 }); |
||||
|
||||
trash._ensureIndex({ rid: 1, __collection__: 1, _deletedAt: 1 }); |
||||
} catch (e) { |
||||
SystemLogger.error(e); |
||||
} |
||||
|
||||
export const trashCollection = trash.rawCollection() as Collection<any>; |
||||
const Trash = new TrashRaw(db); |
||||
export const trashCollection = Trash.col; |
||||
|
||||
@ -0,0 +1,22 @@ |
||||
import type { Db, IndexDescription } from 'mongodb'; |
||||
import type { RocketChatRecordDeleted } from '@rocket.chat/core-typings'; |
||||
|
||||
import { BaseRaw } from './BaseRaw'; |
||||
|
||||
export class TrashRaw extends BaseRaw<RocketChatRecordDeleted<any>> { |
||||
constructor(db: Db) { |
||||
super(db, 'rocketchat__trash', undefined, { |
||||
collectionNameResolver(name) { |
||||
return name; |
||||
}, |
||||
}); |
||||
} |
||||
|
||||
protected modelIndexes(): IndexDescription[] | undefined { |
||||
return [ |
||||
{ key: { __collection__: 1 } }, |
||||
{ key: { _deletedAt: 1 }, expireAfterSeconds: 60 * 60 * 24 * 30 }, |
||||
{ key: { rid: 1, __collection__: 1, _deletedAt: 1 } }, |
||||
]; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue