Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

get all fields of mongoose schema typescript

export const getFieldsFromSchemas = <T extends { paths: { [key: string]: SchemaType<any> } }>(schema: T): string[] => {
	return Object.keys(schema.paths);
};
 
PREVIOUS NEXT
Tagged: #fields #mongoose #schema #typescript
ADD COMMENT
Topic
Name
6+5 =