fix(api): eliminate unsafe lint warnings
This commit is contained in:
1 parent
fd1fa2366c
commit
bb68be14fa
12 files changed
+260
-123
No files matched your search
@@ -34,10 +34,13 @@ type SchemaWithPerformanceMarker = mongoose.Schema & {
|
||||
[PERFORMANCE_PLUGIN_APPLIED]?: boolean;
|
||||
};
|
||||
|
||||
export function applyMongoosePerformancePlugin(schema: mongoose.Schema): void {
|
||||
const markedSchema = schema as SchemaWithPerformanceMarker;
|
||||
if (markedSchema[PERFORMANCE_PLUGIN_APPLIED]) return;
|
||||
markedSchema[PERFORMANCE_PLUGIN_APPLIED] = true;
|
||||
export function applyMongoosePerformancePlugin(schemaValue: unknown): void {
|
||||
if (!(schemaValue instanceof mongoose.Schema)) {
|
||||
throw new TypeError('Mongoose performance plugin requires a Schema.');
|
||||
}
|
||||
const schema = schemaValue as SchemaWithPerformanceMarker;
|
||||
if (schema[PERFORMANCE_PLUGIN_APPLIED]) return;
|
||||
schema[PERFORMANCE_PLUGIN_APPLIED] = true;
|
||||
|
||||
schema.pre(QUERY_OPERATION_REGEX, function () {
|
||||
const query = this as QueryWithPerformanceState;
|
||||
|
||||
Reference in new issue
Block a user