The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/models/server/raw/OEmbedCache.ts

29 lines
703 B

import { DeleteWriteOpResultObject } from 'mongodb';
import { BaseRaw, IndexSpecification } from './BaseRaw';
import { IOEmbedCache } from '../../../../definition/IOEmbedCache';
type T = IOEmbedCache;
export class OEmbedCacheRaw extends BaseRaw<T> {
protected indexes: IndexSpecification[] = [{ key: { updatedAt: 1 } }];
async createWithIdAndData(_id: string, data: any): Promise<T> {
const record = {
_id,
data,
updatedAt: new Date(),
};
record._id = (await this.insertOne(record)).insertedId;
return record;
}
removeAfterDate(date: Date): Promise<DeleteWriteOpResultObject> {
const query = {
updatedAt: {
$lte: date,
},
};
return this.deleteMany(query);
}
}