Files
payload/src/mongoose/getSchemaTypeOptions.ts
2021-10-27 00:49:27 -04:00

10 lines
287 B
TypeScript

import { SchemaType, SchemaTypeOptions } from 'mongoose';
export const getSchemaTypeOptions = (schemaType: SchemaType): SchemaTypeOptions<{ localized: boolean }> => {
if (schemaType?.instance === 'Array') {
return schemaType.options.type[0];
}
return schemaType?.options;
};