hipthrusts - v1.2.0
    Preparing search index...

    Function htMongooseFactory

    • Parameters

      • mongoose: any

      Returns {
          ctxRef: <TPath extends string>(path: TPath) => CtxRef<TPath>;
          documentFactoryFromForRequest: (
              schemaConfigObject: any,
          ) => (initializerPojo: any) => any;
          documentFactoryFromForResponse: (
              schemaConfigObject: any,
          ) => (initializerPojo: any) => any;
          dtoSchemaObj: (schemaConfigObject: any, maskConfig: string) => any;
          findByIdRequired: (
              Model: ModelWithFindById,
          ) => (id: string) => Promise<any>;
          findOneByRequired: (
              Model: ModelWithFindOne,
              fieldName: string,
          ) => (fieldValue: any) => Promise<any>;
          findScoped: <TKey extends string = "scopedDocs">(
              Model: ModelWithFind,
              extraFilter?: object,
              docsKeyOrOptions?: TKey | FindScopedOptions<TKey>,
          ) => {
              execute: (htCtx: TContextIn) => Record<TKey, any[]>[TKey];
              loadResources: (htCtx: HasQueryScope) => Promise;
          };
          FindScoped: <TKey extends string = "scopedDocs">(
              Model: ModelWithFind,
              extraFilter?: object,
              docsKeyOrOptions?: TKey | FindScopedOptions<TKey>,
          ) => {
              execute: (htCtx: TContextIn) => Record<TKey, any[]>[TKey];
              loadResources: (htCtx: HasQueryScope) => Promise;
          };
          LoadByIdRequiredTo: {
              <TRaw, TKey extends string, TPath extends string>(
                  Model: Model<TRaw>,
                  key: TKey,
                  idRef: CtxRef<TPath>,
                  notFoundMessage?: string,
              ): {
                  loadResources: (
                      context: CtxRefReq<TPath>,
                  ) => Promise<Record<TKey, LeanDocOf<TRaw>>>;
              };
              <TRaw, TKey extends string, TCtx extends object>(
                  Model: Model<TRaw>,
                  key: TKey,
                  idSelector: (context: TCtx) => unknown,
                  notFoundMessage?: string,
              ): {
                  loadResources: (
                      context: TCtx,
                  ) => Promise<Record<TKey, LeanDocOf<TRaw>>>;
              };
          };
          LoadDocByIdRequiredTo: {
              <TRaw, TKey extends string, TPath extends string>(
                  Model: Model<TRaw>,
                  key: TKey,
                  idRef: CtxRef<TPath>,
                  notFoundMessage?: string,
              ): {
                  loadResources: (
                      context: CtxRefReq<TPath>,
                  ) => Promise<Record<TKey, HydratedDocument<TRaw>>>;
              };
              <TRaw, TKey extends string, TCtx extends object>(
                  Model: Model<TRaw>,
                  key: TKey,
                  idSelector: (context: TCtx) => unknown,
                  notFoundMessage?: string,
              ): {
                  loadResources: (
                      context: TCtx,
                  ) => Promise<Record<TKey, HydratedDocument<TRaw>>>;
              };
          };
          LoadManyTo: {
              <TRaw, TKey extends string, TSpec extends FilterSpec = {}>(
                  Model: Model<TRaw>,
                  key: TKey,
                  filterSpec?: TSpec,
              ): {
                  loadResources: (
                      context: SpecReq<TSpec>,
                  ) => Promise<Record<TKey, LeanDocOf<TRaw>[]>>;
              };
              <TRaw, TKey extends string, TCtx extends object>(
                  Model: Model<TRaw>,
                  key: TKey,
                  filterSelector: (context: TCtx) => Record<string, unknown>,
              ): {
                  loadResources: (
                      context: TCtx,
                  ) => Promise<Record<TKey, LeanDocOf<TRaw>[]>>;
              };
          };
          LoadOneTo: {
              <TRaw, TKey extends string, TSpec extends FilterSpec = {}>(
                  Model: Model<TRaw>,
                  key: TKey,
                  filterSpec?: TSpec,
              ): {
                  loadResources: (
                      context: SpecReq<TSpec>,
                  ) => Promise<Record<TKey, LeanDocOf<TRaw> | null>>;
              };
              <TRaw, TKey extends string, TCtx extends object>(
                  Model: Model<TRaw>,
                  key: TKey,
                  filterSelector: (context: TCtx) => Record<string, unknown>,
              ): {
                  loadResources: (
                      context: TCtx,
                  ) => Promise<Record<TKey, LeanDocOf<TRaw> | null>>;
              };
          };
          loadScopedTo: <TKey extends string>(
              Model: ModelWithFind,
              docsKey: TKey,
              extraFilter?: object,
              options?: ScopedQueryOptions,
          ) => { loadResources: (htCtx: HasQueryScope) => Promise };
          LoadScopedTo: <TKey extends string>(
              Model: ModelWithFind,
              docsKey: TKey,
              extraFilter?: object,
              options?: ScopedQueryOptions,
          ) => { loadResources: (htCtx: HasQueryScope) => Promise };
          PojoToDocument: <
              TPojoKey extends string,
              TMongooseModel extends Constructor<any>,
              TContextIn extends { [key in string]: any },
          >(
              pojoKey: TPojoKey,
              modelClass: TMongooseModel,
              newDocKey: string,
          ) => { loadResources: (htCtx: TContextIn) => { [key: string]: any } };
          RedactResponseWithMongoose: <
              TSafeResponse extends any,
              TDocFactory extends DocumentFactory<any>,
              TInstance extends HasValidateSync & HasToObject<any>,
          >(
              DocFactory: TDocFactory,
          ) => { redactResponse: (unsafe: any, context?: any) => TSafeResponse };
          SanitizeInputsSlicesWithMongoose: <
              TFactories extends Record<string, DocumentFactory<any>>,
          >(
              factories: TFactories,
              options?: { validateModifiedOnly?: boolean },
          ) => {
              sanitizeInputs: (htCtx: TContextIn) => SafeSlices & HasUnsafeSlices;
          };
          SanitizeInputsWithMongoose: <
              TSafe extends any,
              TDocFactory extends DocumentFactory<any>,
              TInstance extends HasValidateSync & HasToObject<any>,
              TUnsafe extends object,
          >(
              DocFactory: TDocFactory,
              options?: { validateModifiedOnly?: boolean },
          ) => { sanitizeInputs: (htCtx: TUnsafe) => TSafe };
          SaveOnDocumentFrom: (
              propertyKeyOfDocument: string,
          ) => { execute: (htCtx: any) => Promise };
          stripIdTransform: (
              doc: any,
              ret: { _id: any },
              _options: any,
          ) => { _id: any };
          UpdateDocumentFromTo: (
              propertyKeyOfDocument: string,
              propertyKeyWithNewData?: string,
          ) => { execute: (htCtx: any) => Promise };
      }

      • ctxRef: <TPath extends string>(path: TPath) => CtxRef<TPath>
      • documentFactoryFromForRequest: (schemaConfigObject: any) => (initializerPojo: any) => any
      • documentFactoryFromForResponse: (schemaConfigObject: any) => (initializerPojo: any) => any
      • dtoSchemaObj: (schemaConfigObject: any, maskConfig: string) => any
      • findByIdRequired: (Model: ModelWithFindById) => (id: string) => Promise<any>
      • findOneByRequired: (
            Model: ModelWithFindOne,
            fieldName: string,
        ) => (fieldValue: any) => Promise<any>
      • findScoped: <TKey extends string = "scopedDocs">(
            Model: ModelWithFind,
            extraFilter?: object,
            docsKeyOrOptions?: TKey | FindScopedOptions<TKey>,
        ) => {
            execute: (htCtx: TContextIn) => Record<TKey, any[]>[TKey];
            loadResources: (htCtx: HasQueryScope) => Promise;
        }
      • FindScoped: <TKey extends string = "scopedDocs">(
            Model: ModelWithFind,
            extraFilter?: object,
            docsKeyOrOptions?: TKey | FindScopedOptions<TKey>,
        ) => {
            execute: (htCtx: TContextIn) => Record<TKey, any[]>[TKey];
            loadResources: (htCtx: HasQueryScope) => Promise;
        }
      • LoadByIdRequiredTo: {
            <TRaw, TKey extends string, TPath extends string>(
                Model: Model<TRaw>,
                key: TKey,
                idRef: CtxRef<TPath>,
                notFoundMessage?: string,
            ): {
                loadResources: (
                    context: CtxRefReq<TPath>,
                ) => Promise<Record<TKey, LeanDocOf<TRaw>>>;
            };
            <TRaw, TKey extends string, TCtx extends object>(
                Model: Model<TRaw>,
                key: TKey,
                idSelector: (context: TCtx) => unknown,
                notFoundMessage?: string,
            ): {
                loadResources: (
                    context: TCtx,
                ) => Promise<Record<TKey, LeanDocOf<TRaw>>>;
            };
        }
      • LoadDocByIdRequiredTo: {
            <TRaw, TKey extends string, TPath extends string>(
                Model: Model<TRaw>,
                key: TKey,
                idRef: CtxRef<TPath>,
                notFoundMessage?: string,
            ): {
                loadResources: (
                    context: CtxRefReq<TPath>,
                ) => Promise<Record<TKey, HydratedDocument<TRaw>>>;
            };
            <TRaw, TKey extends string, TCtx extends object>(
                Model: Model<TRaw>,
                key: TKey,
                idSelector: (context: TCtx) => unknown,
                notFoundMessage?: string,
            ): {
                loadResources: (
                    context: TCtx,
                ) => Promise<Record<TKey, HydratedDocument<TRaw>>>;
            };
        }
      • LoadManyTo: {
            <TRaw, TKey extends string, TSpec extends FilterSpec = {}>(
                Model: Model<TRaw>,
                key: TKey,
                filterSpec?: TSpec,
            ): {
                loadResources: (
                    context: SpecReq<TSpec>,
                ) => Promise<Record<TKey, LeanDocOf<TRaw>[]>>;
            };
            <TRaw, TKey extends string, TCtx extends object>(
                Model: Model<TRaw>,
                key: TKey,
                filterSelector: (context: TCtx) => Record<string, unknown>,
            ): {
                loadResources: (
                    context: TCtx,
                ) => Promise<Record<TKey, LeanDocOf<TRaw>[]>>;
            };
        }
      • LoadOneTo: {
            <TRaw, TKey extends string, TSpec extends FilterSpec = {}>(
                Model: Model<TRaw>,
                key: TKey,
                filterSpec?: TSpec,
            ): {
                loadResources: (
                    context: SpecReq<TSpec>,
                ) => Promise<Record<TKey, LeanDocOf<TRaw> | null>>;
            };
            <TRaw, TKey extends string, TCtx extends object>(
                Model: Model<TRaw>,
                key: TKey,
                filterSelector: (context: TCtx) => Record<string, unknown>,
            ): {
                loadResources: (
                    context: TCtx,
                ) => Promise<Record<TKey, LeanDocOf<TRaw> | null>>;
            };
        }
      • loadScopedTo: <TKey extends string>(
            Model: ModelWithFind,
            docsKey: TKey,
            extraFilter?: object,
            options?: ScopedQueryOptions,
        ) => { loadResources: (htCtx: HasQueryScope) => Promise }
      • LoadScopedTo: <TKey extends string>(
            Model: ModelWithFind,
            docsKey: TKey,
            extraFilter?: object,
            options?: ScopedQueryOptions,
        ) => { loadResources: (htCtx: HasQueryScope) => Promise }
      • PojoToDocument: <
            TPojoKey extends string,
            TMongooseModel extends Constructor<any>,
            TContextIn extends { [key in string]: any },
        >(
            pojoKey: TPojoKey,
            modelClass: TMongooseModel,
            newDocKey: string,
        ) => { loadResources: (htCtx: TContextIn) => { [key: string]: any } }
      • RedactResponseWithMongoose: <
            TSafeResponse extends any,
            TDocFactory extends DocumentFactory<any>,
            TInstance extends HasValidateSync & HasToObject<any>,
        >(
            DocFactory: TDocFactory,
        ) => { redactResponse: (unsafe: any, context?: any) => TSafeResponse }
      • SanitizeInputsSlicesWithMongoose: <TFactories extends Record<string, DocumentFactory<any>>>(
            factories: TFactories,
            options?: { validateModifiedOnly?: boolean },
        ) => { sanitizeInputs: (htCtx: TContextIn) => SafeSlices & HasUnsafeSlices }
      • SanitizeInputsWithMongoose: <
            TSafe extends any,
            TDocFactory extends DocumentFactory<any>,
            TInstance extends HasValidateSync & HasToObject<any>,
            TUnsafe extends object,
        >(
            DocFactory: TDocFactory,
            options?: { validateModifiedOnly?: boolean },
        ) => { sanitizeInputs: (htCtx: TUnsafe) => TSafe }
      • SaveOnDocumentFrom: (propertyKeyOfDocument: string) => { execute: (htCtx: any) => Promise }
      • stripIdTransform: (doc: any, ret: { _id: any }, _options: any) => { _id: any }
      • UpdateDocumentFromTo: (
            propertyKeyOfDocument: string,
            propertyKeyWithNewData?: string,
        ) => { execute: (htCtx: any) => Promise }