Warn, don't error, on missing PKs in schema

Fixes #3251
This commit is contained in:
rijkvanzanten
2020-12-07 18:24:33 -05:00
parent 9e3f579b22
commit 5bedda945c
2 changed files with 21 additions and 33 deletions

View File

@@ -1,9 +1,20 @@
import { RequestHandler } from 'express';
import asyncHandler from 'express-async-handler';
import { schemaInspector } from '../database';
import logger from '../logger';
const getSchema: RequestHandler = asyncHandler(async (req, res, next) => {
const schemaOverview = await schemaInspector.overview();
for (const [collection, info] of Object.entries(schemaOverview)) {
if (!info.primary) {
logger.warn(
`Collection "${collection}" doesn't have a primary key column and will be ignored`
);
delete schemaOverview[collection];
}
}
req.schema = schemaOverview;
return next();