fix: mongoose

This commit is contained in:
Mohamed Marrouchi
2024-10-26 08:23:02 +01:00
parent 6b387b826b
commit 1b1a0b4b35
3 changed files with 34 additions and 22 deletions

22
api/src/index.d.ts vendored
View File

@@ -8,14 +8,7 @@
import 'mongoose';
import { SubscriberStub } from './chat/schemas/subscriber.schema';
import {
ObjectWithNestedKeys,
RecursivePartial,
WithoutGenericAny,
} from './utils/types/filter.types';
type TOmitId<T> = Omit<T, 'id'>;
type TReplaceId<T> = TOmitId<T> & { _id?: string };
declare module 'express-session' {
interface SessionUser {
id?: string;
@@ -49,21 +42,6 @@ declare module 'express-session' {
}
}
declare module 'mongoose' {
// Enforce the typing with an alternative type to FilterQuery compatible with mongoose: version 8.0.0
type TFilterQuery<T, S = TReplaceId<T>> = (
| RecursivePartial<{
[P in keyof S]?:
| (S[P] extends string ? S[P] | RegExp : S[P])
| QuerySelector<S[P]>;
}>
| Partial<ObjectWithNestedKeys<S>>
) &
WithoutGenericAny<RootQuerySelector<S>>;
type THydratedDocument<T> = TOmitId<HydratedDocument<T>>;
}
declare global {
type HyphenToUnderscore<S extends string> = S extends `${infer P}-${infer Q}`
? `${P}_${HyphenToUnderscore<Q>}`