Sharkey/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts

27 lines
492 B
TypeScript
Raw Normal View History

import define from '../../define';
2021-05-08 06:51:23 +03:00
import { getConnection } from 'typeorm';
export const meta = {
requireCredential: true as const,
requireModerator: true,
tags: ['admin'],
params: {
},
};
export default define(meta, async () => {
const stats = await
getConnection().query(`SELECT * FROM pg_indexes;`)
.then(recs => {
const res = [] as { tablename: string; indexname: string; }[];
for (const rec of recs) {
res.push(rec);
}
return res;
});
return stats;
});