@cyberskill/shared 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/commitlint/index.js +1 -0
- package/dist/config/commitlint/index.js.map +1 -0
- package/dist/config/config.test.unit.d.ts +1 -0
- package/dist/config/config.type.js +1 -0
- package/dist/config/config.type.js.map +1 -0
- package/dist/config/config.type.test.unit.d.ts +1 -0
- package/dist/config/config.util.js +1 -0
- package/dist/config/config.util.js.map +1 -0
- package/dist/config/env/env.constant.js +1 -0
- package/dist/config/env/env.constant.js.map +1 -0
- package/dist/config/env/env.util.js +1 -0
- package/dist/config/env/env.util.js.map +1 -0
- package/dist/config/env/index.js +1 -0
- package/dist/config/env/index.js.map +1 -0
- package/dist/config/eslint/index.js +1 -0
- package/dist/config/eslint/index.js.map +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -0
- package/dist/config/graphql-codegen/index.js +1 -0
- package/dist/config/graphql-codegen/index.js.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/lint-staged/index.js +1 -0
- package/dist/config/lint-staged/index.js.map +1 -0
- package/dist/config/storybook/index.js +1 -0
- package/dist/config/storybook/index.js.map +1 -0
- package/dist/config/storybook/storybook.main.js +1 -0
- package/dist/config/storybook/storybook.main.js.map +1 -0
- package/dist/config/storybook/storybook.preview.js +1 -0
- package/dist/config/storybook/storybook.preview.js.map +1 -0
- package/dist/config/vitest/index.js +1 -0
- package/dist/config/vitest/index.js.map +1 -0
- package/dist/config/vitest/vitest.e2e.js +1 -0
- package/dist/config/vitest/vitest.e2e.js.map +1 -0
- package/dist/config/vitest/vitest.unit.js +1 -0
- package/dist/config/vitest/vitest.unit.js.map +1 -0
- package/dist/constant/common.js +1 -0
- package/dist/constant/common.js.map +1 -0
- package/dist/constant/constant.test.unit.d.ts +1 -0
- package/dist/constant/index.js +1 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/response-status.js +1 -0
- package/dist/constant/response-status.js.map +1 -0
- package/dist/node/apollo-server/apollo-server.util.js +1 -0
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -0
- package/dist/node/apollo-server/index.js +1 -0
- package/dist/node/apollo-server/index.js.map +1 -0
- package/dist/node/cli/index.js +1 -0
- package/dist/node/cli/index.js.map +1 -0
- package/dist/node/command/command.test.unit.d.ts +1 -0
- package/dist/node/command/command.type.js +1 -0
- package/dist/node/command/command.type.js.map +1 -0
- package/dist/node/command/command.util.js +110 -102
- package/dist/node/command/command.util.js.map +1 -0
- package/dist/node/command/index.js +1 -0
- package/dist/node/command/index.js.map +1 -0
- package/dist/node/express/express.type.d.ts +4 -0
- package/dist/node/express/express.util.js +53 -35
- package/dist/node/express/express.util.js.map +1 -0
- package/dist/node/express/index.js +1 -0
- package/dist/node/express/index.js.map +1 -0
- package/dist/node/fs/fs.test.unit.d.ts +1 -0
- package/dist/node/fs/fs.util.js +1 -0
- package/dist/node/fs/fs.util.js.map +1 -0
- package/dist/node/fs/index.js +1 -0
- package/dist/node/fs/index.js.map +1 -0
- package/dist/node/log/index.js +1 -0
- package/dist/node/log/index.js.map +1 -0
- package/dist/node/log/log.test.unit.d.ts +1 -0
- package/dist/node/log/log.type.js +1 -0
- package/dist/node/log/log.type.js.map +1 -0
- package/dist/node/log/log.util.js +1 -0
- package/dist/node/log/log.util.js.map +1 -0
- package/dist/node/mongo/index.d.ts +2 -0
- package/dist/node/mongo/index.js +21 -12
- package/dist/node/mongo/index.js.map +1 -0
- package/dist/node/mongo/mongo.constant.js +1 -0
- package/dist/node/mongo/mongo.constant.js.map +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +5 -315
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +234 -0
- package/dist/node/mongo/mongo.controller.mongoose.js +468 -0
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -0
- package/dist/node/mongo/mongo.controller.native.d.ts +84 -0
- package/dist/node/mongo/mongo.controller.native.js +214 -0
- package/dist/node/mongo/mongo.controller.native.js.map +1 -0
- package/dist/node/mongo/mongo.dynamic-populate.d.ts +61 -0
- package/dist/node/mongo/mongo.dynamic-populate.js +197 -0
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -0
- package/dist/node/mongo/mongo.populate.d.ts +15 -0
- package/dist/node/mongo/mongo.populate.js +269 -0
- package/dist/node/mongo/mongo.populate.js.map +1 -0
- package/dist/node/mongo/mongo.type.js +1 -0
- package/dist/node/mongo/mongo.type.js.map +1 -0
- package/dist/node/mongo/mongo.util.d.ts +52 -0
- package/dist/node/mongo/mongo.util.js +106 -363
- package/dist/node/mongo/mongo.util.js.map +1 -0
- package/dist/node/package/index.js +1 -0
- package/dist/node/package/index.js.map +1 -0
- package/dist/node/package/package.test.unit.d.ts +1 -0
- package/dist/node/package/package.type.js +1 -0
- package/dist/node/package/package.type.js.map +1 -0
- package/dist/node/package/package.util.js +20 -20
- package/dist/node/package/package.util.js.map +1 -0
- package/dist/node/path/index.js +1 -0
- package/dist/node/path/index.js.map +1 -0
- package/dist/node/path/path.constant.js +1 -0
- package/dist/node/path/path.constant.js.map +1 -0
- package/dist/node/path/path.util.js +1 -0
- package/dist/node/path/path.util.js.map +1 -0
- package/dist/node/storage/index.js +1 -0
- package/dist/node/storage/index.js.map +1 -0
- package/dist/node/storage/storage.constant.js +1 -0
- package/dist/node/storage/storage.constant.js.map +1 -0
- package/dist/node/storage/storage.util.js +1 -0
- package/dist/node/storage/storage.util.js.map +1 -0
- package/dist/node/upload/index.js +1 -0
- package/dist/node/upload/index.js.map +1 -0
- package/dist/node/upload/upload.constant.js +1 -0
- package/dist/node/upload/upload.constant.js.map +1 -0
- package/dist/node/upload/upload.type.js +1 -0
- package/dist/node/upload/upload.type.js.map +1 -0
- package/dist/node/upload/upload.util.js +1 -0
- package/dist/node/upload/upload.util.js.map +1 -0
- package/dist/node/ws/index.d.ts +1 -1
- package/dist/node/ws/index.js +2 -1
- package/dist/node/ws/index.js.map +1 -0
- package/dist/node/ws/{ts.util.js → ws.util.js} +1 -0
- package/dist/node/ws/ws.util.js.map +1 -0
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js +1 -0
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +1 -0
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.context.js +1 -0
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.util.js +1 -0
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -0
- package/dist/react/apollo-client/index.js +1 -0
- package/dist/react/apollo-client/index.js.map +1 -0
- package/dist/react/apollo-client/links/index.js +1 -0
- package/dist/react/apollo-client/links/index.js.map +1 -0
- package/dist/react/apollo-client/links/upload.js +1 -0
- package/dist/react/apollo-client/links/upload.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -0
- package/dist/react/apollo-client-nextjs/index.js +1 -0
- package/dist/react/apollo-client-nextjs/index.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.component.js +1 -0
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.context.js +1 -0
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.js +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.util.js +1 -0
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -0
- package/dist/react/apollo-error/index.js +1 -0
- package/dist/react/apollo-error/index.js.map +1 -0
- package/dist/react/i18next/i18next.hook.js +1 -0
- package/dist/react/i18next/i18next.hook.js.map +1 -0
- package/dist/react/i18next/i18next.util.js +1 -0
- package/dist/react/i18next/i18next.util.js.map +1 -0
- package/dist/react/i18next/index.js +1 -0
- package/dist/react/i18next/index.js.map +1 -0
- package/dist/react/loading/index.js +1 -0
- package/dist/react/loading/index.js.map +1 -0
- package/dist/react/loading/loading.component.js +1 -0
- package/dist/react/loading/loading.component.js.map +1 -0
- package/dist/react/loading/loading.context.js +1 -0
- package/dist/react/loading/loading.context.js.map +1 -0
- package/dist/react/loading/loading.hook.js +1 -0
- package/dist/react/loading/loading.hook.js.map +1 -0
- package/dist/react/loading/loading.module.scss.js +1 -0
- package/dist/react/loading/loading.module.scss.js.map +1 -0
- package/dist/react/loading/loading.provider.js +1 -0
- package/dist/react/loading/loading.provider.js.map +1 -0
- package/dist/react/log/index.js +1 -0
- package/dist/react/log/index.js.map +1 -0
- package/dist/react/log/log.util.js +1 -0
- package/dist/react/log/log.util.js.map +1 -0
- package/dist/react/next-intl/index.js +1 -0
- package/dist/react/next-intl/index.js.map +1 -0
- package/dist/react/next-intl/next-intl.constant.js +1 -0
- package/dist/react/next-intl/next-intl.constant.js.map +1 -0
- package/dist/react/next-intl/next-intl.context.js +1 -0
- package/dist/react/next-intl/next-intl.context.js.map +1 -0
- package/dist/react/next-intl/next-intl.hoc.js +1 -0
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -0
- package/dist/react/next-intl/next-intl.hook.js +1 -0
- package/dist/react/next-intl/next-intl.hook.js.map +1 -0
- package/dist/react/next-intl/next-intl.provider.js +1 -0
- package/dist/react/next-intl/next-intl.provider.js.map +1 -0
- package/dist/react/storage/index.js +1 -0
- package/dist/react/storage/index.js.map +1 -0
- package/dist/react/storage/storage.hook.js +1 -0
- package/dist/react/storage/storage.hook.js.map +1 -0
- package/dist/react/storage/storage.test.unit.d.ts +1 -0
- package/dist/react/storage/storage.util.js +1 -0
- package/dist/react/storage/storage.util.js.map +1 -0
- package/dist/react/toast/index.js +1 -0
- package/dist/react/toast/index.js.map +1 -0
- package/dist/react/userback/index.js +1 -0
- package/dist/react/userback/index.js.map +1 -0
- package/dist/react/userback/userback.component.js +1 -0
- package/dist/react/userback/userback.component.js.map +1 -0
- package/dist/typescript/common.type.js +1 -0
- package/dist/typescript/common.type.js.map +1 -0
- package/dist/typescript/index.js +1 -0
- package/dist/typescript/index.js.map +1 -0
- package/dist/typescript/typescript.test.unit.d.ts +1 -0
- package/dist/util/common/common.util.js +1 -0
- package/dist/util/common/common.util.js.map +1 -0
- package/dist/util/common/index.js +1 -0
- package/dist/util/common/index.js.map +1 -0
- package/dist/util/index.js +1 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/object/index.js +1 -0
- package/dist/util/object/index.js.map +1 -0
- package/dist/util/object/object.util.js +1 -0
- package/dist/util/object/object.util.js.map +1 -0
- package/dist/util/serializer/index.js +1 -0
- package/dist/util/serializer/index.js.map +1 -0
- package/dist/util/serializer/serializer.util.js +1 -0
- package/dist/util/serializer/serializer.util.js.map +1 -0
- package/dist/util/string/index.js +1 -0
- package/dist/util/string/index.js.map +1 -0
- package/dist/util/string/string.util.js +1 -0
- package/dist/util/string/string.util.js.map +1 -0
- package/dist/util/validate/index.js +1 -0
- package/dist/util/validate/index.js.map +1 -0
- package/dist/util/validate/validate.util.js +1 -0
- package/dist/util/validate/validate.util.js.map +1 -0
- package/package.json +58 -87
- package/dist/config/commitlint/index.cjs +0 -1
- package/dist/config/config.type.cjs +0 -1
- package/dist/config/config.util.cjs +0 -1
- package/dist/config/env/env.constant.cjs +0 -1
- package/dist/config/env/env.util.cjs +0 -1
- package/dist/config/env/index.cjs +0 -1
- package/dist/config/eslint/index.cjs +0 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
- package/dist/config/graphql-codegen/index.cjs +0 -1
- package/dist/config/index.cjs +0 -1
- package/dist/config/lint-staged/index.cjs +0 -1
- package/dist/config/storybook/index.cjs +0 -1
- package/dist/config/storybook/storybook.main.cjs +0 -1
- package/dist/config/storybook/storybook.preview.cjs +0 -1
- package/dist/config/vitest/index.cjs +0 -1
- package/dist/config/vitest/vitest.e2e.cjs +0 -1
- package/dist/config/vitest/vitest.unit.cjs +0 -1
- package/dist/constant/common.cjs +0 -1
- package/dist/constant/index.cjs +0 -1
- package/dist/constant/response-status.cjs +0 -1
- package/dist/node/apollo-server/apollo-server.util.cjs +0 -1
- package/dist/node/apollo-server/index.cjs +0 -1
- package/dist/node/cli/index.cjs +0 -3
- package/dist/node/command/command.type.cjs +0 -1
- package/dist/node/command/command.util.cjs +0 -2
- package/dist/node/command/index.cjs +0 -1
- package/dist/node/express/express.util.cjs +0 -1
- package/dist/node/express/index.cjs +0 -1
- package/dist/node/fs/fs.util.cjs +0 -4
- package/dist/node/fs/index.cjs +0 -1
- package/dist/node/log/index.cjs +0 -1
- package/dist/node/log/log.type.cjs +0 -1
- package/dist/node/log/log.util.cjs +0 -1
- package/dist/node/mongo/index.cjs +0 -1
- package/dist/node/mongo/mongo.constant.cjs +0 -1
- package/dist/node/mongo/mongo.controller.cjs +0 -1
- package/dist/node/mongo/mongo.controller.js +0 -858
- package/dist/node/mongo/mongo.type.cjs +0 -1
- package/dist/node/mongo/mongo.util.cjs +0 -2
- package/dist/node/package/index.cjs +0 -1
- package/dist/node/package/package.type.cjs +0 -1
- package/dist/node/package/package.util.cjs +0 -1
- package/dist/node/path/index.cjs +0 -1
- package/dist/node/path/path.constant.cjs +0 -1
- package/dist/node/path/path.util.cjs +0 -1
- package/dist/node/storage/index.cjs +0 -1
- package/dist/node/storage/storage.constant.cjs +0 -1
- package/dist/node/storage/storage.util.cjs +0 -1
- package/dist/node/upload/index.cjs +0 -1
- package/dist/node/upload/upload.constant.cjs +0 -1
- package/dist/node/upload/upload.type.cjs +0 -1
- package/dist/node/upload/upload.util.cjs +0 -1
- package/dist/node/ws/index.cjs +0 -1
- package/dist/node/ws/ts.util.cjs +0 -1
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.component.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.constant.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.context.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.module.scss.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.util.cjs +0 -1
- package/dist/react/apollo-client/index.cjs +0 -1
- package/dist/react/apollo-client/links/index.cjs +0 -1
- package/dist/react/apollo-client/links/upload.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
- package/dist/react/apollo-client-nextjs/index.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.component.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.context.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.hook.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.provider.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.util.cjs +0 -1
- package/dist/react/apollo-error/index.cjs +0 -1
- package/dist/react/i18next/i18next.hook.cjs +0 -1
- package/dist/react/i18next/i18next.util.cjs +0 -1
- package/dist/react/i18next/index.cjs +0 -1
- package/dist/react/loading/index.cjs +0 -1
- package/dist/react/loading/loading.component.cjs +0 -6
- package/dist/react/loading/loading.context.cjs +0 -1
- package/dist/react/loading/loading.hook.cjs +0 -1
- package/dist/react/loading/loading.module.scss.cjs +0 -1
- package/dist/react/loading/loading.provider.cjs +0 -1
- package/dist/react/log/index.cjs +0 -1
- package/dist/react/log/log.util.cjs +0 -1
- package/dist/react/next-intl/index.cjs +0 -1
- package/dist/react/next-intl/next-intl.constant.cjs +0 -1
- package/dist/react/next-intl/next-intl.context.cjs +0 -1
- package/dist/react/next-intl/next-intl.hoc.cjs +0 -1
- package/dist/react/next-intl/next-intl.hook.cjs +0 -1
- package/dist/react/next-intl/next-intl.provider.cjs +0 -1
- package/dist/react/storage/index.cjs +0 -1
- package/dist/react/storage/storage.hook.cjs +0 -1
- package/dist/react/storage/storage.util.cjs +0 -1
- package/dist/react/toast/index.cjs +0 -1
- package/dist/react/userback/index.cjs +0 -1
- package/dist/react/userback/userback.component.cjs +0 -1
- package/dist/typescript/common.type.cjs +0 -1
- package/dist/typescript/index.cjs +0 -1
- package/dist/util/common/common.util.cjs +0 -1
- package/dist/util/common/index.cjs +0 -1
- package/dist/util/index.cjs +0 -1
- package/dist/util/object/index.cjs +0 -1
- package/dist/util/object/object.util.cjs +0 -1
- package/dist/util/serializer/index.cjs +0 -1
- package/dist/util/serializer/serializer.util.cjs +0 -1
- package/dist/util/string/index.cjs +0 -1
- package/dist/util/string/string.util.cjs +0 -1
- package/dist/util/validate/index.cjs +0 -1
- package/dist/util/validate/validate.util.cjs +0 -1
- /package/dist/node/ws/{ts.util.d.ts → ws.util.d.ts} +0 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { MONGO_SLUG_MAX_ATTEMPTS as S } from "./mongo.constant.js";
|
|
2
|
+
import { populateDynamicVirtuals as f, filterDynamicVirtualsFromPopulate as y, isObject as O } from "./mongo.dynamic-populate.js";
|
|
3
|
+
import { normalizeMongoFilter as d } from "../../util/object/object.util.js";
|
|
4
|
+
import { generateShortId as b, generateSlug as p, generateRandomString as V } from "../../util/string/string.util.js";
|
|
5
|
+
import { RESPONSE_STATUS as g } from "../../constant/response-status.js";
|
|
6
|
+
import { catchError as u } from "../log/log.util.js";
|
|
7
|
+
class R {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new Mongoose controller instance.
|
|
10
|
+
*
|
|
11
|
+
* @param model - The Mongoose model to operate on.
|
|
12
|
+
*/
|
|
13
|
+
constructor(r) {
|
|
14
|
+
this.model = r;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Gets the model name for logging and error messages.
|
|
18
|
+
*
|
|
19
|
+
* @returns The name of the model.
|
|
20
|
+
*/
|
|
21
|
+
getModelName() {
|
|
22
|
+
return this.model.modelName;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the dynamic virtuals configuration from the model instance.
|
|
26
|
+
*
|
|
27
|
+
* @returns Array of dynamic virtual configurations or undefined if none exist.
|
|
28
|
+
*/
|
|
29
|
+
getDynamicVirtuals() {
|
|
30
|
+
if (this.model._virtualConfigs) {
|
|
31
|
+
const s = this.model._virtualConfigs.filter((t) => typeof t.options?.ref == "function");
|
|
32
|
+
if (s.length > 0)
|
|
33
|
+
return s;
|
|
34
|
+
}
|
|
35
|
+
return this.model.schema.statics._dynamicVirtuals;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Populates dynamic virtuals for a single document.
|
|
39
|
+
*
|
|
40
|
+
* @param result - The document to populate dynamic virtuals for.
|
|
41
|
+
* @param populate - The populate options to determine which virtuals to populate.
|
|
42
|
+
* @returns The document with dynamic virtuals populated.
|
|
43
|
+
*/
|
|
44
|
+
async populateDynamicVirtualsForDocument(r, e) {
|
|
45
|
+
const s = this.getDynamicVirtuals();
|
|
46
|
+
if (s && s.length > 0) {
|
|
47
|
+
const t = await f(this.model.base, [r], s, e, void 0, this.model);
|
|
48
|
+
return t && t[0] ? t[0] : r;
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Populates dynamic virtuals for an array of documents.
|
|
54
|
+
*
|
|
55
|
+
* @param results - The documents to populate dynamic virtuals for.
|
|
56
|
+
* @param populate - The populate options to determine which virtuals to populate.
|
|
57
|
+
* @returns The documents with dynamic virtuals populated.
|
|
58
|
+
*/
|
|
59
|
+
async populateDynamicVirtualsForDocuments(r, e) {
|
|
60
|
+
const s = this.getDynamicVirtuals();
|
|
61
|
+
return s && s.length > 0 && r.length > 0 ? await f(this.model.base, r, s, e, void 0, this.model) : r;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Finds a single document with optional population and projection.
|
|
65
|
+
* Automatically handles dynamic virtual population if configured.
|
|
66
|
+
*
|
|
67
|
+
* @param filter - The filter criteria to find the document.
|
|
68
|
+
* @param projection - The fields to include/exclude in the result.
|
|
69
|
+
* @param options - Query options for the operation.
|
|
70
|
+
* @param populate - Population configuration for related documents.
|
|
71
|
+
* @returns A promise that resolves to a standardized response with the found document.
|
|
72
|
+
*/
|
|
73
|
+
async findOne(r = {}, e = {}, s = {}, t) {
|
|
74
|
+
try {
|
|
75
|
+
const a = d(r), c = this.model.findOne(a, e, s).maxTimeMS(3e4).lean(), n = this.getDynamicVirtuals(), i = y(t, n);
|
|
76
|
+
i && c.populate(i);
|
|
77
|
+
const o = await c.exec();
|
|
78
|
+
if (!o)
|
|
79
|
+
return {
|
|
80
|
+
success: !1,
|
|
81
|
+
message: `No ${this.getModelName()} found.`,
|
|
82
|
+
code: g.NOT_FOUND.CODE
|
|
83
|
+
};
|
|
84
|
+
const l = await this.populateDynamicVirtualsForDocument(o, t);
|
|
85
|
+
return { success: !0, result: l?.toObject?.() ?? l };
|
|
86
|
+
} catch (a) {
|
|
87
|
+
return u(a);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Finds all documents with optional population and projection.
|
|
92
|
+
* Automatically handles dynamic virtual population if configured.
|
|
93
|
+
*
|
|
94
|
+
* @param filter - The filter criteria to find documents.
|
|
95
|
+
* @param projection - The fields to include/exclude in the result.
|
|
96
|
+
* @param options - Query options for the operation.
|
|
97
|
+
* @param populate - Population configuration for related documents.
|
|
98
|
+
* @returns A promise that resolves to a standardized response with the found documents.
|
|
99
|
+
*/
|
|
100
|
+
async findAll(r = {}, e = {}, s = {}, t) {
|
|
101
|
+
try {
|
|
102
|
+
const a = d(r), c = this.model.find(a, e, s).maxTimeMS(3e4).lean();
|
|
103
|
+
s.limit || c.limit(1e4);
|
|
104
|
+
const n = this.getDynamicVirtuals(), i = y(t, n);
|
|
105
|
+
i && c.populate(i);
|
|
106
|
+
const o = await c.exec();
|
|
107
|
+
return { success: !0, result: (await this.populateDynamicVirtualsForDocuments(o, t)).map((m) => m?.toObject?.() ?? m) };
|
|
108
|
+
} catch (a) {
|
|
109
|
+
return u(a);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Finds documents with pagination support.
|
|
114
|
+
* Automatically handles dynamic virtual population if configured.
|
|
115
|
+
*
|
|
116
|
+
* @param filter - The filter criteria to find documents.
|
|
117
|
+
* @param options - Pagination options including page, limit, and population.
|
|
118
|
+
* @returns A promise that resolves to a standardized response with paginated results.
|
|
119
|
+
*/
|
|
120
|
+
async findPaging(r = {}, e = {}) {
|
|
121
|
+
try {
|
|
122
|
+
const s = d(r), t = this.getDynamicVirtuals(), a = { ...e };
|
|
123
|
+
e.populate && (a.populate = y(e.populate, t));
|
|
124
|
+
const c = await this.model.paginate(s, a);
|
|
125
|
+
if (t && t.length > 0) {
|
|
126
|
+
const n = await this.populateDynamicVirtualsForDocuments(c.docs, e.populate);
|
|
127
|
+
return { success: !0, result: { ...c, docs: n.map((i) => i?.toObject?.() ?? i) } };
|
|
128
|
+
}
|
|
129
|
+
return { success: !0, result: { ...c, docs: c.docs.map((n) => n?.toObject?.() ?? n) } };
|
|
130
|
+
} catch (s) {
|
|
131
|
+
return u(s);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Performs aggregation with pagination support.
|
|
136
|
+
*
|
|
137
|
+
* @param pipeline - The aggregation pipeline stages.
|
|
138
|
+
* @param options - Pagination options for the aggregation result.
|
|
139
|
+
* @returns A promise that resolves to a standardized response with paginated aggregation results.
|
|
140
|
+
*/
|
|
141
|
+
async findPagingAggregate(r, e = {}) {
|
|
142
|
+
try {
|
|
143
|
+
const s = this.getDynamicVirtuals(), t = { ...e };
|
|
144
|
+
e.populate && (t.populate = y(e.populate, s));
|
|
145
|
+
const a = await this.model.aggregatePaginate(
|
|
146
|
+
this.model.aggregate(r),
|
|
147
|
+
t
|
|
148
|
+
), c = await this.populateDynamicVirtualsForDocuments(a.docs, e.populate);
|
|
149
|
+
return { success: !0, result: { ...a, docs: c.map((n) => n?.toObject?.() ?? n) } };
|
|
150
|
+
} catch (s) {
|
|
151
|
+
return u(s);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Counts documents matching the filter criteria.
|
|
156
|
+
*
|
|
157
|
+
* @param filter - The filter criteria to count documents.
|
|
158
|
+
* @returns A promise that resolves to a standardized response with the document count.
|
|
159
|
+
*/
|
|
160
|
+
async count(r = {}) {
|
|
161
|
+
try {
|
|
162
|
+
const e = d(r);
|
|
163
|
+
return { success: !0, result: await this.model.countDocuments(e) };
|
|
164
|
+
} catch (e) {
|
|
165
|
+
return u(e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a single document.
|
|
170
|
+
*
|
|
171
|
+
* @param doc - The document to create.
|
|
172
|
+
* @returns A promise that resolves to a standardized response with the created document.
|
|
173
|
+
*/
|
|
174
|
+
async createOne(r) {
|
|
175
|
+
try {
|
|
176
|
+
const e = await this.model.create(r);
|
|
177
|
+
return { success: !0, result: e?.toObject?.() ?? e };
|
|
178
|
+
} catch (e) {
|
|
179
|
+
return u(e);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Creates multiple documents with bulk insertion.
|
|
184
|
+
*
|
|
185
|
+
* @param docs - An array of documents to create.
|
|
186
|
+
* @param options - Options for the bulk insertion operation.
|
|
187
|
+
* @returns A promise that resolves to a standardized response with the created documents.
|
|
188
|
+
*/
|
|
189
|
+
async createMany(r, e = {}) {
|
|
190
|
+
try {
|
|
191
|
+
return { success: !0, result: (await this.model.insertMany(r, e)).map((t) => t?.toObject?.() ?? t) };
|
|
192
|
+
} catch (s) {
|
|
193
|
+
return u(s);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Updates a single document and returns the updated version.
|
|
198
|
+
*
|
|
199
|
+
* @param filter - The filter criteria to find the document to update.
|
|
200
|
+
* @param update - The update data to apply.
|
|
201
|
+
* @param options - Options for the update operation.
|
|
202
|
+
* @returns A promise that resolves to a standardized response with the updated document.
|
|
203
|
+
*/
|
|
204
|
+
async updateOne(r = {}, e = {}, s = {}) {
|
|
205
|
+
try {
|
|
206
|
+
const t = d(r), a = await this.model.findOneAndUpdate(t, e, {
|
|
207
|
+
new: !0,
|
|
208
|
+
...s
|
|
209
|
+
}).exec();
|
|
210
|
+
return a ? { success: !0, result: a?.toObject?.() ?? a } : {
|
|
211
|
+
success: !1,
|
|
212
|
+
message: `Failed to update ${this.getModelName()}.`,
|
|
213
|
+
code: g.NOT_FOUND.CODE
|
|
214
|
+
};
|
|
215
|
+
} catch (t) {
|
|
216
|
+
return u(t);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Updates multiple documents matching the filter criteria.
|
|
221
|
+
*
|
|
222
|
+
* @param filter - The filter criteria to find documents to update.
|
|
223
|
+
* @param update - The update data to apply.
|
|
224
|
+
* @param options - Options for the update operation.
|
|
225
|
+
* @returns A promise that resolves to a standardized response with the update result.
|
|
226
|
+
*/
|
|
227
|
+
async updateMany(r = {}, e = {}, s = {}) {
|
|
228
|
+
try {
|
|
229
|
+
const t = d(r);
|
|
230
|
+
return { success: !0, result: await this.model.updateMany(t, e, s).exec() };
|
|
231
|
+
} catch (t) {
|
|
232
|
+
return u(t);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Deletes a single document and returns the deleted version.
|
|
237
|
+
*
|
|
238
|
+
* @param filter - The filter criteria to find the document to delete.
|
|
239
|
+
* @param options - Options for the delete operation.
|
|
240
|
+
* @returns A promise that resolves to a standardized response with the deleted document.
|
|
241
|
+
*/
|
|
242
|
+
async deleteOne(r = {}, e = {}) {
|
|
243
|
+
try {
|
|
244
|
+
const s = d(r), t = await this.model.findOneAndDelete(s, e).exec();
|
|
245
|
+
return t ? { success: !0, result: t?.toObject?.() ?? t } : {
|
|
246
|
+
success: !1,
|
|
247
|
+
message: `No ${this.getModelName()} found to delete.`,
|
|
248
|
+
code: g.NOT_FOUND.CODE
|
|
249
|
+
};
|
|
250
|
+
} catch (s) {
|
|
251
|
+
return u(s);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Deletes multiple documents matching the filter criteria.
|
|
256
|
+
*
|
|
257
|
+
* @param filter - The filter criteria to find documents to delete.
|
|
258
|
+
* @param options - Options for the delete operation.
|
|
259
|
+
* @returns A promise that resolves to a standardized response with the delete result.
|
|
260
|
+
*/
|
|
261
|
+
async deleteMany(r = {}, e = {}) {
|
|
262
|
+
try {
|
|
263
|
+
const s = d(r), t = await this.model.deleteMany(s, e).exec();
|
|
264
|
+
return t.deletedCount === 0 ? {
|
|
265
|
+
success: !1,
|
|
266
|
+
message: "No documents found to delete.",
|
|
267
|
+
code: g.NOT_FOUND.CODE
|
|
268
|
+
} : { success: !0, result: t };
|
|
269
|
+
} catch (s) {
|
|
270
|
+
return u(s);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Creates a unique short ID based on a given ID.
|
|
275
|
+
* This method generates multiple short IDs with increasing lengths and finds the first available one.
|
|
276
|
+
*
|
|
277
|
+
* @param id - The base ID to generate short IDs from.
|
|
278
|
+
* @param length - The initial length for short ID generation (default: 4).
|
|
279
|
+
* @returns A promise that resolves to a standardized response with the unique short ID.
|
|
280
|
+
*/
|
|
281
|
+
async createShortId(r, e = 4) {
|
|
282
|
+
try {
|
|
283
|
+
const t = Array.from({ length: 10 }, (n, i) => b(r, i + e)), c = (await Promise.all(
|
|
284
|
+
t.map((n) => this.model.exists({ shortId: n }))
|
|
285
|
+
)).findIndex((n) => !n);
|
|
286
|
+
if (c !== -1) {
|
|
287
|
+
const n = t[c];
|
|
288
|
+
if (n)
|
|
289
|
+
return { success: !0, result: n };
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
success: !1,
|
|
293
|
+
message: "Failed to create a unique shortId",
|
|
294
|
+
code: g.INTERNAL_SERVER_ERROR.CODE
|
|
295
|
+
};
|
|
296
|
+
} catch (s) {
|
|
297
|
+
return u(s);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Creates a query for slug existence checking.
|
|
302
|
+
* This method generates a query that checks for slug existence in both current and historical slug fields.
|
|
303
|
+
*
|
|
304
|
+
* @param options - Configuration for slug query generation including slug, field, and filter.
|
|
305
|
+
* @param options.slug - The slug string to check for existence.
|
|
306
|
+
* @param options.field - The field name for object-based slug checking.
|
|
307
|
+
* @param options.isObject - Whether the slug is stored as an object with nested fields.
|
|
308
|
+
* @param options.haveHistory - Whether to check historical slug fields for existence.
|
|
309
|
+
* @param options.filter - Additional filter conditions to apply to the query.
|
|
310
|
+
* @returns A MongoDB query object for checking slug existence.
|
|
311
|
+
*/
|
|
312
|
+
createSlugQuery({ slug: r, field: e, isObject: s, haveHistory: t = !1, filter: a }) {
|
|
313
|
+
const c = { ...a ?? {} };
|
|
314
|
+
return s ? {
|
|
315
|
+
...c,
|
|
316
|
+
$or: [
|
|
317
|
+
{ [`slug.${e}`]: r },
|
|
318
|
+
...t ? [{ slugHistory: { $elemMatch: { [`slug.${e}`]: r } } }] : []
|
|
319
|
+
]
|
|
320
|
+
} : {
|
|
321
|
+
...c,
|
|
322
|
+
$or: [
|
|
323
|
+
{ slug: r },
|
|
324
|
+
...t ? [{ slugHistory: r }] : []
|
|
325
|
+
]
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Creates a unique slug based on a given string.
|
|
330
|
+
* This method generates multiple slug variations and finds the first available one.
|
|
331
|
+
*
|
|
332
|
+
* @param options - Configuration for slug generation including slug, field, and filter.
|
|
333
|
+
* @param options.slug - The base slug string to make unique.
|
|
334
|
+
* @param options.field - The field name for object-based slug checking.
|
|
335
|
+
* @param options.isObject - Whether the slug is stored as an object with nested fields.
|
|
336
|
+
* @param options.haveHistory - Whether to check historical slug fields for uniqueness.
|
|
337
|
+
* @param options.filter - Additional filter conditions to apply when checking slug existence.
|
|
338
|
+
* @returns A promise that resolves to a unique slug string.
|
|
339
|
+
*/
|
|
340
|
+
async createUniqueSlug({ slug: r, field: e, isObject: s, haveHistory: t, filter: a }) {
|
|
341
|
+
if (!r || typeof r != "string")
|
|
342
|
+
throw new Error("Invalid slug provided: must be a non-empty string");
|
|
343
|
+
const c = p(r);
|
|
344
|
+
if (!await this.model.exists(
|
|
345
|
+
this.createSlugQuery({ slug: c, field: e, isObject: s, haveHistory: t, filter: a })
|
|
346
|
+
))
|
|
347
|
+
return c;
|
|
348
|
+
for (let l = 1; l <= S; l++) {
|
|
349
|
+
const m = `${c}-${l}`;
|
|
350
|
+
if (!await this.model.exists(
|
|
351
|
+
this.createSlugQuery({ slug: m, field: e, isObject: s, haveHistory: t, filter: a })
|
|
352
|
+
))
|
|
353
|
+
return m;
|
|
354
|
+
}
|
|
355
|
+
const i = Date.now(), o = V(6);
|
|
356
|
+
return `${c}-${i}-${o}`;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Creates a slug for a document field.
|
|
360
|
+
* This method handles both simple string fields and object fields with nested slug generation.
|
|
361
|
+
*
|
|
362
|
+
* @param options - Configuration for slug creation including field, source document, and filter.
|
|
363
|
+
* @param options.field - The field name to create a slug for.
|
|
364
|
+
* @param options.from - The source document containing the field value.
|
|
365
|
+
* @param options.haveHistory - Whether to check historical slug fields for uniqueness.
|
|
366
|
+
* @param options.filter - Additional filter conditions to apply when checking slug existence.
|
|
367
|
+
* @returns A promise that resolves to a standardized response with the created slug(s).
|
|
368
|
+
*/
|
|
369
|
+
async createSlug({ field: r, from: e, filter: s, haveHistory: t }) {
|
|
370
|
+
try {
|
|
371
|
+
const a = e[r];
|
|
372
|
+
return O(a) ? { success: !0, result: Object.fromEntries(
|
|
373
|
+
await Promise.all(
|
|
374
|
+
Object.entries(a).map(async ([o, l]) => {
|
|
375
|
+
const m = await this.createUniqueSlug({
|
|
376
|
+
slug: l,
|
|
377
|
+
field: o,
|
|
378
|
+
isObject: !0,
|
|
379
|
+
haveHistory: t,
|
|
380
|
+
filter: s
|
|
381
|
+
});
|
|
382
|
+
return [o, m];
|
|
383
|
+
})
|
|
384
|
+
)
|
|
385
|
+
) } : { success: !0, result: await this.createUniqueSlug({
|
|
386
|
+
slug: a,
|
|
387
|
+
field: r,
|
|
388
|
+
isObject: !1,
|
|
389
|
+
haveHistory: t,
|
|
390
|
+
filter: s
|
|
391
|
+
}) };
|
|
392
|
+
} catch (a) {
|
|
393
|
+
return u(a);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Checks if a slug already exists in the collection.
|
|
398
|
+
* This method verifies slug existence in both current and historical slug fields.
|
|
399
|
+
*
|
|
400
|
+
* @param options - Configuration for slug checking including slug, field, source document, and filter.
|
|
401
|
+
* @param options.slug - The slug string to check for existence.
|
|
402
|
+
* @param options.field - The field name for object-based slug checking.
|
|
403
|
+
* @param options.from - The source document containing the field value.
|
|
404
|
+
* @param options.haveHistory - Whether to check historical slug fields for existence.
|
|
405
|
+
* @param options.filter - Additional filter conditions to apply to the query.
|
|
406
|
+
* @returns A promise that resolves to a standardized response indicating whether the slug exists.
|
|
407
|
+
*/
|
|
408
|
+
async checkSlug({ slug: r, field: e, from: s, filter: t, haveHistory: a }) {
|
|
409
|
+
try {
|
|
410
|
+
const c = s[e];
|
|
411
|
+
if (O(c)) {
|
|
412
|
+
const m = Object.values(c).map((h) => p(h));
|
|
413
|
+
return (await Promise.all(
|
|
414
|
+
m.map(
|
|
415
|
+
(h) => this.model.exists(this.createSlugQuery({
|
|
416
|
+
slug: h,
|
|
417
|
+
field: e,
|
|
418
|
+
isObject: !0,
|
|
419
|
+
haveHistory: a,
|
|
420
|
+
filter: t
|
|
421
|
+
}))
|
|
422
|
+
)
|
|
423
|
+
)).some((h) => h) ? { success: !0, result: !0 } : { success: !0, result: !1 };
|
|
424
|
+
}
|
|
425
|
+
const i = p(r);
|
|
426
|
+
return { success: !0, result: await this.model.exists(this.createSlugQuery({
|
|
427
|
+
slug: i,
|
|
428
|
+
field: e,
|
|
429
|
+
isObject: !1,
|
|
430
|
+
filter: t
|
|
431
|
+
})) !== null };
|
|
432
|
+
} catch (c) {
|
|
433
|
+
return u(c);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Performs aggregation operations on the collection.
|
|
438
|
+
*
|
|
439
|
+
* @param pipeline - The aggregation pipeline stages to execute.
|
|
440
|
+
* @returns A promise that resolves to a standardized response with the aggregation results.
|
|
441
|
+
*/
|
|
442
|
+
async aggregate(r) {
|
|
443
|
+
try {
|
|
444
|
+
return { success: !0, result: await this.model.aggregate(r) };
|
|
445
|
+
} catch (e) {
|
|
446
|
+
return u(e);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Retrieves distinct values for the specified key from the collection.
|
|
451
|
+
*
|
|
452
|
+
* @param key - The field for which to return distinct values.
|
|
453
|
+
* @param filter - The filter query to apply (optional).
|
|
454
|
+
* @param options - Additional options for the distinct operation (optional).
|
|
455
|
+
* @returns A promise that resolves to a standardized response with the array of distinct values.
|
|
456
|
+
*/
|
|
457
|
+
async distinct(r, e = {}, s = {}) {
|
|
458
|
+
try {
|
|
459
|
+
return { success: !0, result: await this.model.distinct(r, e, s) };
|
|
460
|
+
} catch (t) {
|
|
461
|
+
return u(t);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
export {
|
|
466
|
+
R as MongooseController
|
|
467
|
+
};
|
|
468
|
+
//# sourceMappingURL=mongo.controller.mongoose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.controller.mongoose.js","sources":["../../../src/node/mongo/mongo.controller.mongoose.ts"],"sourcesContent":["import type { I_Return } from '#typescript/index.js';\n\nimport { RESPONSE_STATUS } from '#constant/index.js';\nimport { normalizeMongoFilter } from '#util/index.js';\nimport { generateRandomString, generateShortId, generateSlug } from '#util/string/index.js';\n\nimport type { C_Document, I_DeleteOptionsExtended, I_DynamicVirtualConfig, I_ExtendedModel, I_Input_CheckSlug, I_Input_CreateSlug, I_Input_GenerateSlug, I_PaginateOptionsWithPopulate, I_UpdateOptionsExtended, T_AggregatePaginateResult, T_DeleteResult, T_Input_Populate, T_InsertManyOptions, T_PaginateResult, T_PipelineStage, T_PopulateOptions, T_ProjectionType, T_QueryFilter, T_QueryOptions, T_UpdateQuery, T_UpdateResult } from './mongo.type.js';\n\nimport { catchError } from '../log/index.js';\nimport { MONGO_SLUG_MAX_ATTEMPTS } from './mongo.constant.js';\nimport { filterDynamicVirtualsFromPopulate, isObject, populateDynamicVirtuals } from './mongo.dynamic-populate.js';\n\n/**\n * Mongoose controller for database operations with advanced features.\n * This class provides a comprehensive interface for Mongoose operations including\n * pagination, aggregation, slug generation, and short ID creation.\n */\nexport class MongooseController<T extends Partial<C_Document>> {\n /**\n * Creates a new Mongoose controller instance.\n *\n * @param model - The Mongoose model to operate on.\n */\n constructor(private model: I_ExtendedModel<T>) { }\n\n /**\n * Gets the model name for logging and error messages.\n *\n * @returns The name of the model.\n */\n private getModelName(): string {\n return this.model.modelName;\n }\n\n /**\n * Gets the dynamic virtuals configuration from the model instance.\n *\n * @returns Array of dynamic virtual configurations or undefined if none exist.\n */\n private getDynamicVirtuals(): I_DynamicVirtualConfig<T>[] | undefined {\n if ((this.model as any)._virtualConfigs) {\n const allVirtuals = (this.model as any)._virtualConfigs as Array<{ name: string; options?: { ref?: unknown } }>;\n const dynamicOnly = allVirtuals.filter(v => typeof (v.options as { ref?: unknown } | undefined)?.ref === 'function') as unknown as I_DynamicVirtualConfig<T>[];\n\n if (dynamicOnly.length > 0) {\n return dynamicOnly;\n }\n }\n\n const schemaStatics = this.model.schema.statics as { [key: string]: unknown };\n\n return schemaStatics['_dynamicVirtuals'] as I_DynamicVirtualConfig<T>[] | undefined;\n }\n\n /**\n * Populates dynamic virtuals for a single document.\n *\n * @param result - The document to populate dynamic virtuals for.\n * @param populate - The populate options to determine which virtuals to populate.\n * @returns The document with dynamic virtuals populated.\n */\n private async populateDynamicVirtualsForDocument(result: T, populate?: T_Input_Populate): Promise<T> {\n const dynamicVirtuals = this.getDynamicVirtuals();\n\n if (dynamicVirtuals && dynamicVirtuals.length > 0) {\n const populatedArr = await populateDynamicVirtuals(this.model.base, [result], dynamicVirtuals, populate, undefined, this.model);\n\n return (populatedArr && populatedArr[0]) ? populatedArr[0] as T : result;\n }\n\n return result;\n }\n\n /**\n * Populates dynamic virtuals for an array of documents.\n *\n * @param results - The documents to populate dynamic virtuals for.\n * @param populate - The populate options to determine which virtuals to populate.\n * @returns The documents with dynamic virtuals populated.\n */\n private async populateDynamicVirtualsForDocuments(results: T[], populate?: T_Input_Populate): Promise<T[]> {\n const dynamicVirtuals = this.getDynamicVirtuals();\n\n if (dynamicVirtuals && dynamicVirtuals.length > 0 && results.length > 0) {\n const populatedResults = await populateDynamicVirtuals(this.model.base, results, dynamicVirtuals, populate, undefined, this.model) as T[];\n\n return populatedResults;\n }\n\n return results;\n }\n\n /**\n * Finds a single document with optional population and projection.\n * Automatically handles dynamic virtual population if configured.\n *\n * @param filter - The filter criteria to find the document.\n * @param projection - The fields to include/exclude in the result.\n * @param options - Query options for the operation.\n * @param populate - Population configuration for related documents.\n * @returns A promise that resolves to a standardized response with the found document.\n */\n async findOne(\n filter: T_QueryFilter<T> = {},\n projection: T_ProjectionType<T> = {},\n options: T_QueryOptions<T> = {},\n populate?: T_Input_Populate,\n ): Promise<I_Return<T>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const query = this.model.findOne(normalizedFilter, projection, options).maxTimeMS(30_000).lean();\n const dynamicVirtuals = this.getDynamicVirtuals();\n\n const regularPopulate = filterDynamicVirtualsFromPopulate(populate, dynamicVirtuals);\n\n if (regularPopulate) {\n query.populate(regularPopulate as T_PopulateOptions);\n }\n\n const result = await query.exec();\n\n if (!result) {\n return {\n success: false,\n message: `No ${this.getModelName()} found.`,\n code: RESPONSE_STATUS.NOT_FOUND.CODE,\n };\n }\n\n const finalResult = await this.populateDynamicVirtualsForDocument(result, populate);\n\n return { success: true, result: finalResult?.toObject?.() ?? finalResult };\n }\n catch (error) {\n return catchError<T>(error);\n }\n }\n\n /**\n * Finds all documents with optional population and projection.\n * Automatically handles dynamic virtual population if configured.\n *\n * @param filter - The filter criteria to find documents.\n * @param projection - The fields to include/exclude in the result.\n * @param options - Query options for the operation.\n * @param populate - Population configuration for related documents.\n * @returns A promise that resolves to a standardized response with the found documents.\n */\n async findAll(\n filter: T_QueryFilter<T> = {},\n projection: T_ProjectionType<T> = {},\n options: T_QueryOptions<T> = {},\n populate?: T_Input_Populate,\n ): Promise<I_Return<T[]>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const query = this.model.find(normalizedFilter, projection, options).maxTimeMS(30_000).lean();\n\n if (!options.limit) {\n query.limit(10_000);\n }\n const dynamicVirtuals = this.getDynamicVirtuals();\n\n const regularPopulate = filterDynamicVirtualsFromPopulate(populate, dynamicVirtuals);\n\n if (regularPopulate) {\n query.populate(regularPopulate as T_PopulateOptions);\n }\n\n const result = await query.exec();\n\n const finalResult = await this.populateDynamicVirtualsForDocuments(result, populate);\n\n return { success: true, result: finalResult.map(item => item?.toObject?.() ?? item) };\n }\n catch (error) {\n return catchError<T[]>(error);\n }\n }\n\n /**\n * Finds documents with pagination support.\n * Automatically handles dynamic virtual population if configured.\n *\n * @param filter - The filter criteria to find documents.\n * @param options - Pagination options including page, limit, and population.\n * @returns A promise that resolves to a standardized response with paginated results.\n */\n async findPaging(\n filter: T_QueryFilter<T> = {},\n options: I_PaginateOptionsWithPopulate = {},\n ): Promise<I_Return<T_PaginateResult<T>>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const dynamicVirtuals = this.getDynamicVirtuals();\n\n const filteredOptions = { ...options };\n\n if (options.populate) {\n filteredOptions.populate = filterDynamicVirtualsFromPopulate(options.populate, dynamicVirtuals);\n }\n\n const result = await this.model.paginate(normalizedFilter, filteredOptions);\n\n if (dynamicVirtuals && dynamicVirtuals.length > 0) {\n const populatedDocs = await this.populateDynamicVirtualsForDocuments(result.docs, options.populate);\n\n return { success: true, result: { ...result, docs: populatedDocs.map(item => item?.toObject?.() ?? item) } };\n }\n\n return { success: true, result: { ...result, docs: result.docs.map(item => item?.toObject?.() ?? item) } };\n }\n catch (error) {\n return catchError<T_PaginateResult<T>>(error);\n }\n }\n\n /**\n * Performs aggregation with pagination support.\n *\n * @param pipeline - The aggregation pipeline stages.\n * @param options - Pagination options for the aggregation result.\n * @returns A promise that resolves to a standardized response with paginated aggregation results.\n */\n async findPagingAggregate(\n pipeline: T_PipelineStage[],\n options: I_PaginateOptionsWithPopulate = {},\n ): Promise<I_Return<T_AggregatePaginateResult<T>>> {\n try {\n const dynamicVirtuals = this.getDynamicVirtuals();\n\n const filteredOptions = { ...options };\n\n if (options.populate) {\n filteredOptions.populate = filterDynamicVirtualsFromPopulate(options.populate, dynamicVirtuals);\n }\n\n const result = await this.model.aggregatePaginate(\n this.model.aggregate(pipeline),\n filteredOptions,\n );\n\n const finalDocs = await this.populateDynamicVirtualsForDocuments(result.docs, options.populate);\n\n return { success: true, result: { ...result, docs: finalDocs.map(item => item?.toObject?.() ?? item) } };\n }\n catch (error) {\n return catchError<T_AggregatePaginateResult<T>>(error);\n }\n }\n\n /**\n * Counts documents matching the filter criteria.\n *\n * @param filter - The filter criteria to count documents.\n * @returns A promise that resolves to a standardized response with the document count.\n */\n async count(filter: T_QueryFilter<T> = {}): Promise<I_Return<number>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const result = await this.model.countDocuments(normalizedFilter);\n\n return { success: true, result };\n }\n catch (error) {\n return catchError<number>(error);\n }\n }\n\n /**\n * Creates a single document.\n *\n * @param doc - The document to create.\n * @returns A promise that resolves to a standardized response with the created document.\n */\n async createOne(doc: T | Partial<T>): Promise<I_Return<T>> {\n try {\n const result = await this.model.create(doc as unknown as Parameters<typeof this.model.create>[0]);\n\n return { success: true, result: (result as T)?.toObject?.() ?? result };\n }\n catch (error) {\n return catchError<T>(error);\n }\n }\n\n /**\n * Creates multiple documents with bulk insertion.\n *\n * @param docs - An array of documents to create.\n * @param options - Options for the bulk insertion operation.\n * @returns A promise that resolves to a standardized response with the created documents.\n */\n async createMany(\n docs: (T | Partial<T>)[],\n options: T_InsertManyOptions = {},\n ): Promise<I_Return<T[]>> {\n try {\n const createdDocuments = await this.model.insertMany(docs, options);\n\n return { success: true, result: createdDocuments.map(item => item?.toObject?.() ?? item) as T[] };\n }\n catch (error) {\n return catchError<T[]>(error);\n }\n }\n\n /**\n * Updates a single document and returns the updated version.\n *\n * @param filter - The filter criteria to find the document to update.\n * @param update - The update data to apply.\n * @param options - Options for the update operation.\n * @returns A promise that resolves to a standardized response with the updated document.\n */\n async updateOne(\n filter: T_QueryFilter<T> = {},\n update: T_UpdateQuery<T> = {},\n options: I_UpdateOptionsExtended = {},\n ): Promise<I_Return<T>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const result = await this.model\n .findOneAndUpdate(normalizedFilter, update, {\n new: true,\n ...options,\n })\n .exec();\n\n if (!result) {\n return {\n success: false,\n message: `Failed to update ${this.getModelName()}.`,\n code: RESPONSE_STATUS.NOT_FOUND.CODE,\n };\n }\n\n return { success: true, result: result?.toObject?.() ?? result };\n }\n catch (error) {\n return catchError<T>(error);\n }\n }\n\n /**\n * Updates multiple documents matching the filter criteria.\n *\n * @param filter - The filter criteria to find documents to update.\n * @param update - The update data to apply.\n * @param options - Options for the update operation.\n * @returns A promise that resolves to a standardized response with the update result.\n */\n async updateMany(\n filter: T_QueryFilter<T> = {},\n update: T_UpdateQuery<T> = {},\n options: I_UpdateOptionsExtended = {},\n ): Promise<I_Return<T_UpdateResult>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const result = await this.model\n .updateMany(normalizedFilter, update, options)\n .exec();\n\n return { success: true, result };\n }\n catch (error) {\n return catchError<T_UpdateResult>(error);\n }\n }\n\n /**\n * Deletes a single document and returns the deleted version.\n *\n * @param filter - The filter criteria to find the document to delete.\n * @param options - Options for the delete operation.\n * @returns A promise that resolves to a standardized response with the deleted document.\n */\n async deleteOne(\n filter: T_QueryFilter<T> = {},\n options: I_DeleteOptionsExtended = {},\n ): Promise<I_Return<T>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const result = await this.model\n .findOneAndDelete(normalizedFilter, options)\n .exec();\n\n if (!result) {\n return {\n success: false,\n message: `No ${this.getModelName()} found to delete.`,\n code: RESPONSE_STATUS.NOT_FOUND.CODE,\n };\n }\n\n return { success: true, result: result?.toObject?.() ?? result };\n }\n catch (error) {\n return catchError<T>(error);\n }\n }\n\n /**\n * Deletes multiple documents matching the filter criteria.\n *\n * @param filter - The filter criteria to find documents to delete.\n * @param options - Options for the delete operation.\n * @returns A promise that resolves to a standardized response with the delete result.\n */\n async deleteMany(\n filter: T_QueryFilter<T> = {},\n options: I_DeleteOptionsExtended = {},\n ): Promise<I_Return<T_DeleteResult>> {\n try {\n const normalizedFilter = normalizeMongoFilter(filter);\n const result = await this.model.deleteMany(normalizedFilter, options).exec();\n\n if (result.deletedCount === 0) {\n return {\n success: false,\n message: `No documents found to delete.`,\n code: RESPONSE_STATUS.NOT_FOUND.CODE,\n };\n }\n\n return { success: true, result };\n }\n catch (error) {\n return catchError<T_DeleteResult>(error);\n }\n }\n\n /**\n * Creates a unique short ID based on a given ID.\n * This method generates multiple short IDs with increasing lengths and finds the first available one.\n *\n * @param id - The base ID to generate short IDs from.\n * @param length - The initial length for short ID generation (default: 4).\n * @returns A promise that resolves to a standardized response with the unique short ID.\n */\n async createShortId(id: string, length = 4): Promise<I_Return<string>> {\n try {\n const maxRetries = 10;\n const shortIds = Array.from({ length: maxRetries }, (_, index) =>\n generateShortId(id, index + length));\n\n const existenceChecks = await Promise.all(\n shortIds.map(shortId => this.model.exists({ shortId })),\n );\n\n const availableIndex = existenceChecks.findIndex(exists => !exists);\n\n if (availableIndex !== -1) {\n const availableShortId = shortIds[availableIndex];\n\n if (availableShortId) {\n return { success: true, result: availableShortId };\n }\n }\n\n return {\n success: false,\n message: 'Failed to create a unique shortId',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n catch (error) {\n return catchError<string>(error);\n }\n }\n\n /**\n * Creates a query for slug existence checking.\n * This method generates a query that checks for slug existence in both current and historical slug fields.\n *\n * @param options - Configuration for slug query generation including slug, field, and filter.\n * @param options.slug - The slug string to check for existence.\n * @param options.field - The field name for object-based slug checking.\n * @param options.isObject - Whether the slug is stored as an object with nested fields.\n * @param options.haveHistory - Whether to check historical slug fields for existence.\n * @param options.filter - Additional filter conditions to apply to the query.\n * @returns A MongoDB query object for checking slug existence.\n */\n createSlugQuery({ slug, field, isObject, haveHistory = false, filter }: I_Input_GenerateSlug<T>) {\n const baseFilter = { ...(filter ?? {}) };\n\n return isObject\n ? {\n ...baseFilter,\n $or: [\n { [`slug.${field}`]: slug },\n ...(haveHistory ? [{ slugHistory: { $elemMatch: { [`slug.${field}`]: slug } } }] : []),\n ],\n }\n : {\n ...baseFilter,\n $or: [\n { slug },\n ...(haveHistory ? [{ slugHistory: slug }] : []),\n ],\n };\n }\n\n /**\n * Creates a unique slug based on a given string.\n * This method generates multiple slug variations and finds the first available one.\n *\n * @param options - Configuration for slug generation including slug, field, and filter.\n * @param options.slug - The base slug string to make unique.\n * @param options.field - The field name for object-based slug checking.\n * @param options.isObject - Whether the slug is stored as an object with nested fields.\n * @param options.haveHistory - Whether to check historical slug fields for uniqueness.\n * @param options.filter - Additional filter conditions to apply when checking slug existence.\n * @returns A promise that resolves to a unique slug string.\n */\n async createUniqueSlug({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): Promise<string> {\n if (!slug || typeof slug !== 'string') {\n throw new Error('Invalid slug provided: must be a non-empty string');\n }\n\n const baseSlug = generateSlug(slug);\n\n const baseExists = await this.model.exists(\n this.createSlugQuery({ slug: baseSlug, field, isObject, haveHistory, filter }),\n );\n\n if (!baseExists) {\n return baseSlug;\n }\n\n for (let index = 1; index <= MONGO_SLUG_MAX_ATTEMPTS; index++) {\n const slugVariation = `${baseSlug}-${index}`;\n\n const exists = await this.model.exists(\n this.createSlugQuery({ slug: slugVariation, field, isObject, haveHistory, filter }),\n );\n\n if (!exists) {\n return slugVariation;\n }\n }\n\n const timestamp = Date.now();\n const randomSuffix = generateRandomString(6);\n\n return `${baseSlug}-${timestamp}-${randomSuffix}`;\n }\n\n /**\n * Creates a slug for a document field.\n * This method handles both simple string fields and object fields with nested slug generation.\n *\n * @param options - Configuration for slug creation including field, source document, and filter.\n * @param options.field - The field name to create a slug for.\n * @param options.from - The source document containing the field value.\n * @param options.haveHistory - Whether to check historical slug fields for uniqueness.\n * @param options.filter - Additional filter conditions to apply when checking slug existence.\n * @returns A promise that resolves to a standardized response with the created slug(s).\n */\n async createSlug<R = string>({ field, from, filter, haveHistory }: I_Input_CreateSlug<T>): Promise<I_Return<R>> {\n try {\n const fieldValue = from[field as keyof T];\n const isObjectValue = isObject(fieldValue);\n\n if (isObjectValue) {\n const uniqueSlug = Object.fromEntries(\n await Promise.all(\n Object.entries(fieldValue).map(async ([key, value]) => {\n const uniqueSlugForKey = await this.createUniqueSlug({\n slug: value as string,\n field: key,\n isObject: true,\n haveHistory,\n filter,\n });\n return [key, uniqueSlugForKey];\n }),\n ),\n );\n\n return { success: true, result: uniqueSlug as R };\n }\n\n const uniqueSlug = await this.createUniqueSlug({\n slug: fieldValue as string,\n field,\n isObject: false,\n haveHistory,\n filter,\n });\n\n return { success: true, result: uniqueSlug as R };\n }\n catch (error) {\n return catchError<R>(error);\n }\n }\n\n /**\n * Checks if a slug already exists in the collection.\n * This method verifies slug existence in both current and historical slug fields.\n *\n * @param options - Configuration for slug checking including slug, field, source document, and filter.\n * @param options.slug - The slug string to check for existence.\n * @param options.field - The field name for object-based slug checking.\n * @param options.from - The source document containing the field value.\n * @param options.haveHistory - Whether to check historical slug fields for existence.\n * @param options.filter - Additional filter conditions to apply to the query.\n * @returns A promise that resolves to a standardized response indicating whether the slug exists.\n */\n async checkSlug({ slug, field, from, filter, haveHistory }: I_Input_CheckSlug<T>): Promise<I_Return<boolean>> {\n try {\n const fieldValue = from[field as keyof T];\n const isObjectValue = isObject(fieldValue);\n\n if (isObjectValue) {\n const values = Object.values(fieldValue);\n const nestedSlugs = values.map(value => generateSlug(value as string));\n\n const existenceChecks = await Promise.all(\n nestedSlugs.map(nestedSlug =>\n this.model.exists(this.createSlugQuery({\n slug: nestedSlug,\n field,\n isObject: true,\n haveHistory,\n filter,\n })),\n ),\n );\n\n if (existenceChecks.some(exists => exists)) {\n return { success: true, result: true };\n }\n\n return { success: true, result: false };\n }\n\n const baseSlug = generateSlug(slug);\n const exists = await this.model.exists(this.createSlugQuery({\n slug: baseSlug,\n field,\n isObject: false,\n filter,\n }));\n\n return { success: true, result: exists !== null };\n }\n catch (error) {\n return catchError<boolean>(error);\n }\n }\n\n /**\n * Performs aggregation operations on the collection.\n *\n * @param pipeline - The aggregation pipeline stages to execute.\n * @returns A promise that resolves to a standardized response with the aggregation results.\n */\n async aggregate(pipeline: T_PipelineStage[]): Promise<I_Return<T[]>> {\n try {\n const result = await this.model.aggregate<T>(pipeline);\n\n return { success: true, result };\n }\n catch (error) {\n return catchError<T[]>(error);\n }\n }\n\n /**\n * Retrieves distinct values for the specified key from the collection.\n *\n * @param key - The field for which to return distinct values.\n * @param filter - The filter query to apply (optional).\n * @param options - Additional options for the distinct operation (optional).\n * @returns A promise that resolves to a standardized response with the array of distinct values.\n */\n async distinct(\n key: string,\n filter: T_QueryFilter<T> = {},\n options: T_QueryOptions<T> = {},\n ): Promise<I_Return<unknown[]>> {\n try {\n const result = await this.model.distinct(key, filter, options);\n\n return { success: true, result };\n }\n catch (error) {\n return catchError<unknown[]>(error);\n }\n }\n}\n"],"names":["MONGO_SLUG_MAX_ATTEMPTS","populateDynamicVirtuals","filterDynamicVirtualsFromPopulate","isObject","normalizeMongoFilter","generateShortId","generateSlug","generateRandomString","RESPONSE_STATUS","catchError","MongooseController","model","dynamicOnly","v","result","populate","dynamicVirtuals","populatedArr","results","filter","projection","options","normalizedFilter","query","regularPopulate","finalResult","error","item","filteredOptions","populatedDocs","pipeline","finalDocs","doc","docs","update","id","length","shortIds","_","index","availableIndex","shortId","exists","availableShortId","slug","field","haveHistory","baseFilter","baseSlug","slugVariation","timestamp","randomSuffix","from","fieldValue","key","value","uniqueSlugForKey","uniqueSlug","nestedSlugs","nestedSlug"],"mappings":"AAiBO,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MAAM,UAAaA,CAAQ,EAE7B;AAAA,IAC5B,SACOJ,GAAO;AACV,aAAOjB,EAAgBiB,CAAK;AAAA,IAChC;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,SACF4B,GACAnC,IAA2B,CAAA,GAC3BE,IAA6B,CAAA,GACD;AAC5B,QAAI;AAGA,aAAO,EAAE,SAAS,IAAM,QAFT,MAAM,KAAK,MAAM,SAASiC,GAAKnC,GAAQE,CAAO,EAErC;AAAA,IAC5B,SACOK,GAAO;AACV,aAAOjB,EAAsBiB,CAAK;AAAA,IACtC;AAAA,EACJ;AACJ;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { I_Return } from '../../typescript/index.js';
|
|
2
|
+
import { C_Db, C_Document, T_DeleteResult, T_Filter, T_UpdateResult, T_WithId } from './mongo.type.js';
|
|
3
|
+
/**
|
|
4
|
+
* MongoDB native driver controller for direct database operations.
|
|
5
|
+
* This class provides a simplified interface for MongoDB operations using the native driver,
|
|
6
|
+
* with automatic generic field generation and standardized response formatting.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MongoController<D extends Partial<C_Document>> {
|
|
9
|
+
private collection;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new MongoDB controller instance.
|
|
12
|
+
*
|
|
13
|
+
* @param db - The MongoDB database instance.
|
|
14
|
+
* @param collectionName - The name of the collection to operate on.
|
|
15
|
+
*/
|
|
16
|
+
constructor(db: C_Db, collectionName: string);
|
|
17
|
+
/**
|
|
18
|
+
* Creates a single document in the collection.
|
|
19
|
+
* This method adds generic fields (id, isDel, timestamps) to the document before insertion.
|
|
20
|
+
*
|
|
21
|
+
* @param document - The document to create, with or without generic fields.
|
|
22
|
+
* @returns A promise that resolves to a standardized response with the created document.
|
|
23
|
+
*/
|
|
24
|
+
createOne(document: D | Partial<D>): Promise<I_Return<D | Partial<D>>>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates multiple documents in the collection.
|
|
27
|
+
* This method adds generic fields to each document before bulk insertion.
|
|
28
|
+
*
|
|
29
|
+
* @param documents - An array of documents to create.
|
|
30
|
+
* @returns A promise that resolves to a standardized response with the created documents.
|
|
31
|
+
*/
|
|
32
|
+
createMany(documents: (D | Partial<D>)[]): Promise<I_Return<(D | Partial<D>)[]>>;
|
|
33
|
+
/**
|
|
34
|
+
* Finds a single document by filter criteria.
|
|
35
|
+
*
|
|
36
|
+
* @param filter - The filter criteria to find the document.
|
|
37
|
+
* @returns A promise that resolves to a standardized response with the found document.
|
|
38
|
+
*/
|
|
39
|
+
findOne(filter: T_Filter<D>): Promise<I_Return<T_WithId<D>>>;
|
|
40
|
+
/**
|
|
41
|
+
* Finds all documents matching the filter criteria.
|
|
42
|
+
*
|
|
43
|
+
* @param filter - The filter criteria to find documents (defaults to empty object for all documents).
|
|
44
|
+
* @returns A promise that resolves to a standardized response with the found documents.
|
|
45
|
+
*/
|
|
46
|
+
findAll(filter?: T_Filter<D>): Promise<I_Return<T_WithId<D>[]>>;
|
|
47
|
+
/**
|
|
48
|
+
* Counts documents matching the filter criteria.
|
|
49
|
+
*
|
|
50
|
+
* @param filter - The filter criteria to count documents (defaults to empty object for all documents).
|
|
51
|
+
* @returns A promise that resolves to a standardized response with the document count.
|
|
52
|
+
*/
|
|
53
|
+
count(filter?: T_Filter<D>): Promise<I_Return<number>>;
|
|
54
|
+
/**
|
|
55
|
+
* Updates a single document matching the filter criteria.
|
|
56
|
+
*
|
|
57
|
+
* @param filter - The filter criteria to find the document to update.
|
|
58
|
+
* @param update - The update data to apply to the document.
|
|
59
|
+
* @returns A promise that resolves to a standardized response with the update result.
|
|
60
|
+
*/
|
|
61
|
+
updateOne(filter: T_Filter<D>, update: Partial<D>): Promise<I_Return<T_UpdateResult>>;
|
|
62
|
+
/**
|
|
63
|
+
* Updates multiple documents matching the filter criteria.
|
|
64
|
+
*
|
|
65
|
+
* @param filter - The filter criteria to find documents to update.
|
|
66
|
+
* @param update - The update data to apply to the documents.
|
|
67
|
+
* @returns A promise that resolves to a standardized response with the update result.
|
|
68
|
+
*/
|
|
69
|
+
updateMany(filter: T_Filter<D>, update: Partial<D>): Promise<I_Return<T_UpdateResult>>;
|
|
70
|
+
/**
|
|
71
|
+
* Deletes a single document matching the filter criteria.
|
|
72
|
+
*
|
|
73
|
+
* @param filter - The filter criteria to find the document to delete.
|
|
74
|
+
* @returns A promise that resolves to a standardized response with the delete result.
|
|
75
|
+
*/
|
|
76
|
+
deleteOne(filter: T_Filter<D>): Promise<I_Return<T_DeleteResult>>;
|
|
77
|
+
/**
|
|
78
|
+
* Deletes multiple documents matching the filter criteria.
|
|
79
|
+
*
|
|
80
|
+
* @param filter - The filter criteria to find documents to delete.
|
|
81
|
+
* @returns A promise that resolves to a standardized response with the delete result.
|
|
82
|
+
*/
|
|
83
|
+
deleteMany(filter: T_Filter<D>): Promise<I_Return<T_DeleteResult>>;
|
|
84
|
+
}
|