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/apps/meteor/server/models/raw/Statistics.ts

28 lines
629 B

import type { IStats } from '@rocket.chat/core-typings';
import type { IStatisticsModel } from '@rocket.chat/model-typings';
import type { Db, IndexDescription } from 'mongodb';
import { BaseRaw } from './BaseRaw';
export class StatisticsRaw extends BaseRaw<IStats> implements IStatisticsModel {
constructor(db: Db) {
super(db, 'statistics');
}
protected modelIndexes(): IndexDescription[] {
return [{ key: { createdAt: -1 } }];
}
async findLast(): Promise<IStats> {
const records = await this.find(
{},
{
sort: {
createdAt: -1,
},
limit: 1,
},
).toArray();
return records?.[0];
}
}