333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
{"version":3,"sources":["../browser/src/connection/BaseConnectionOptions.ts"],"names":[],"mappings":"","file":"BaseConnectionOptions.js","sourcesContent":["import {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {LoggerOptions} from \"../logger/LoggerOptions\";\nimport {NamingStrategyInterface} from \"../naming-strategy/NamingStrategyInterface\";\nimport {DatabaseType} from \"../driver/types/DatabaseType\";\nimport {Logger} from \"../logger/Logger\";\n\n/**\n * BaseConnectionOptions is set of connection options shared by all database types.\n */\nexport interface BaseConnectionOptions {\n\n    /**\n     * Database type. This value is required.\n     */\n    readonly type: DatabaseType;\n\n    /**\n     * Connection name. If connection name is not given then it will be called \"default\".\n     * Different connections must have different names.\n     */\n    readonly name?: string;\n\n    /**\n     * Entities to be loaded for this connection.\n     * Accepts both entity classes and directories where from entities need to be loaded.\n     * Directories support glob patterns.\n     */\n    readonly entities?: ((Function|string|EntitySchema<any>))[];\n\n    /**\n     * Subscribers to be loaded for this connection.\n     * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n     * Directories support glob patterns.\n     */\n    readonly subscribers?: (Function|string)[];\n\n    /**\n     * Migrations to be loaded for this connection.\n     * Accepts both migration classes and directories where from migrations need to be loaded.\n     * Directories support glob patterns.\n     */\n    readonly migrations?: (Function|string)[];\n\n    /**\n     * Migrations table name, in case of different name from \"migrations\".\n     * Accepts single string name.\n     */\n    readonly migrationsTableName?: string;\n\n    /**\n     * Naming strategy to be used to name tables and columns in the database.\n     */\n    readonly namingStrategy?: NamingStrategyInterface;\n\n    /**\n     * Logging options.\n     */\n    readonly logging?: LoggerOptions;\n\n    /**\n     * Logger instance used to log queries and events in the ORM.\n     */\n    readonly logger?: \"advanced-console\"|\"simple-console\"|\"file\"|\"debug\"|Logger;\n\n    /**\n     * Maximum number of milliseconds query should be executed before logger log a warning.\n     */\n    readonly maxQueryExecutionTime?: number;\n\n    /**\n     * Indicates if database schema should be auto created on every application launch.\n     * Be careful with this option and don't use this in production - otherwise you can lose production data.\n     * This option is useful during debug and development.\n     * Alternative to it, you can use CLI and run schema:sync command.\n     *\n     * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n     * Instead, it syncs just by creating indices.\n     */\n    readonly synchronize?: boolean;\n\n    /**\n     * Indicates if migrations should be auto run on every application launch.\n     * Alternative to it, you can use CLI and run migrations:run command.\n     */\n    readonly migrationsRun?: boolean;\n\n    /**\n     * Drops the schema each time connection is being established.\n     * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n     * This option is useful during debug and development.\n     */\n    readonly dropSchema?: boolean;\n\n    /**\n     * Prefix to use on all tables (collections) of this connection in the database.\n     */\n    readonly entityPrefix?: string;\n\n    /**\n     * Extra connection options to be passed to the underlying driver.\n     *\n     * todo: deprecate this and move all database-specific types into hts own connection options object.\n     */\n    readonly extra?: any;\n\n    /**\n     * Allows to setup cache options.\n     */\n    readonly cache?: boolean|{\n\n        /**\n         * Type of caching.\n         *\n         * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n         * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n         */\n        readonly type?: \"database\" | \"redis\" | \"ioredis\" | \"ioredis/cluster\"; // todo: add mongodb and other cache providers as well in the future\n\n        /**\n         * Configurable table name for \"database\" type cache.\n         * Default value is \"query-result-cache\"\n         */\n        readonly tableName?: string;\n\n        /**\n         * Used to provide redis connection options.\n         */\n        readonly options?: any;\n\n        /**\n         * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n         */\n        readonly alwaysEnabled?: boolean;\n\n        /**\n         * Time in milliseconds in which cache will expire.\n         * This can be setup per-query.\n         * Default value is 1000 which is equivalent to 1 second.\n         */\n        readonly duration?: number;\n\n    };\n\n    /**\n     * CLI settings.\n     */\n    readonly cli?: {\n\n        /**\n         * Directory where entities should be created by default.\n         */\n        readonly entitiesDir?: string;\n\n        /**\n         * Directory where migrations should be created by default.\n         */\n        readonly migrationsDir?: string;\n\n        /**\n         * Directory where subscribers should be created by default.\n         */\n        readonly subscribersDir?: string;\n\n    };\n\n}\n"],"sourceRoot":".."}