fib-orm 2.1.0 → 3.0.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/README.md +42 -6
- package/index.d.ts +11 -0
- package/index.js +15 -0
- package/package.json +37 -34
- package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -27
- package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -32
- package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -29
- package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -11
- package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -34
- package/src/cli/helpers/ddl.ts +84 -0
- package/src/cli/helpers/package.ts +81 -0
- package/src/cli/index.ts +24 -0
- package/src/cli/wrapSubcommand.ts +66 -0
- package/src/db-driver/Typo.d.ts +141 -0
- package/src/db-driver/built-ins/base.class.ts +260 -0
- package/src/db-driver/built-ins/driver-dm.ts +62 -0
- package/src/db-driver/built-ins/driver-mssql.ts +67 -0
- package/src/db-driver/built-ins/driver-mysql.ts +44 -0
- package/src/db-driver/built-ins/driver-postgresql.ts +94 -0
- package/src/db-driver/built-ins/driver-redis.ts +45 -0
- package/src/db-driver/built-ins/driver-sqlite.ts +41 -0
- package/src/db-driver/index.ts +6 -0
- package/src/db-driver/parseQueryString.ts +76 -0
- package/src/db-driver/utils.ts +204 -0
- package/src/knex/deps/tarn/PendingOperation.ts +56 -0
- package/src/knex/deps/tarn/Pool.ts +610 -0
- package/src/knex/deps/tarn/PromiseInspection.ts +29 -0
- package/src/knex/deps/tarn/Resource.ts +22 -0
- package/src/knex/deps/tarn/TimeoutError.ts +1 -0
- package/src/knex/deps/tarn/tarn.ts +7 -0
- package/src/knex/deps/tarn/utils.ts +62 -0
- package/src/knex/knex.ts +11 -0
- package/src/knex/result.d.ts +27 -0
- package/src/knex/sandbox.ts +45 -0
- package/src/knex/tables.d.ts +4 -0
- package/src/knex/types.d.ts +3228 -0
- package/src/orm/Adapters.ts +53 -0
- package/src/orm/AggregateFunctions.ts +254 -0
- package/src/orm/Associations/Extend.ts +405 -0
- package/src/orm/Associations/Many.ts +784 -0
- package/src/orm/Associations/One.ts +494 -0
- package/src/orm/Associations/_utils.ts +72 -0
- package/src/orm/ChainFind.ts +427 -0
- package/src/orm/ChainInstance.ts +97 -0
- package/src/orm/Debug.ts +21 -0
- package/src/orm/Drivers/DB/base.ts +7 -0
- package/src/orm/Drivers/DB/dm.ts +35 -0
- package/src/orm/Drivers/DB/mssql.ts +35 -0
- package/src/orm/Drivers/DB/mysql.ts +35 -0
- package/src/orm/Drivers/DB/postgres.ts +35 -0
- package/src/orm/Drivers/DB/sqlite3.ts +60 -0
- package/src/orm/Drivers/DML/_ddl-sql.ts +85 -0
- package/src/orm/Drivers/DML/_dml-helpers.ts +66 -0
- package/src/orm/Drivers/DML/_shared.ts +61 -0
- package/src/orm/Drivers/DML/_utils.ts +112 -0
- package/{lib/orm/Drivers/DML/dm.js → src/orm/Drivers/DML/dm.ts} +178 -86
- package/src/orm/Drivers/DML/index.ts +10 -0
- package/src/orm/Drivers/DML/mssql.ts +366 -0
- package/src/orm/Drivers/DML/mysql.ts +347 -0
- package/src/orm/Drivers/DML/postgres.ts +382 -0
- package/src/orm/Drivers/DML/sqlite.ts +361 -0
- package/src/orm/Error.ts +49 -0
- package/src/orm/Helpers.ts +297 -0
- package/src/orm/Hook.ts +125 -0
- package/src/orm/Instance.ts +944 -0
- package/src/orm/LazyLoad.ts +117 -0
- package/src/orm/Model.ts +1235 -0
- package/src/orm/ORM.ts +301 -0
- package/src/orm/Patch/fib-cache.ts +7 -0
- package/src/orm/Patch/plugin.ts +25 -0
- package/src/orm/Property.ts +86 -0
- package/src/orm/Settings.ts +134 -0
- package/src/orm/Singleton.ts +97 -0
- package/src/orm/Typo/Adapter.d.ts +5 -0
- package/src/orm/Typo/DMLDriver.d.ts +260 -0
- package/src/orm/Typo/Db.d.ts +100 -0
- package/src/orm/Typo/Error.d.ts +36 -0
- package/src/orm/Typo/ORM.d.ts +315 -0
- package/src/orm/Typo/Validators.d.ts +39 -0
- package/src/orm/Typo/_common.d.ts +44 -0
- package/src/orm/Typo/assoc.d.ts +280 -0
- package/src/orm/Typo/hook.d.ts +68 -0
- package/src/orm/Typo/instance.d.ts +214 -0
- package/{lib → src}/orm/Typo/model.d.ts +297 -174
- package/src/orm/Typo/patch.d.ts +39 -0
- package/src/orm/Typo/property.d.ts +79 -0
- package/src/orm/Typo/query.d.ts +266 -0
- package/{lib → src}/orm/Typo/settings.d.ts +14 -7
- package/{lib → src}/orm/Typo/synchronous.d.ts +51 -26
- package/src/orm/Utilities.ts +1313 -0
- package/src/orm/Validators.ts +127 -0
- package/src/orm/Where/common.ts +8 -0
- package/src/orm/Where/filterDate.ts +74 -0
- package/src/orm/cloneDeep.ts +45 -0
- package/src/orm/index.ts +231 -0
- package/src/orm-core/callback.d.ts +15 -0
- package/{lib → src}/orm-core/dialect.d.ts +75 -52
- package/src/orm-core/error.ts +71 -0
- package/{lib/orm-core/index.d.ts → src/orm-core/index.ts} +8 -2
- package/src/orm-core/sync.d.ts +14 -0
- package/src/orm-core/utils.ts +4 -0
- package/src/orm-property/Property.ts +110 -0
- package/src/orm-property/Utils.ts +26 -0
- package/src/orm-property/customTypes.ts +13 -0
- package/src/orm-property/index.ts +34 -0
- package/src/orm-property/transformer.ts +16 -0
- package/{lib/orm-property/transformers/dm.js → src/orm-property/transformers/dm.ts} +128 -69
- package/src/orm-property/transformers/index.ts +10 -0
- package/src/orm-property/transformers/mssql.ts +285 -0
- package/src/orm-property/transformers/mysql.ts +395 -0
- package/src/orm-property/transformers/postgresql.ts +267 -0
- package/src/orm-property/transformers/sqlite.ts +217 -0
- package/src/plugins/orm-plugin-uacl/Typo.d.ts +173 -0
- package/src/plugins/orm-plugin-uacl/_utils.ts +237 -0
- package/src/plugins/orm-plugin-uacl/acl-tree.ts +440 -0
- package/src/plugins/orm-plugin-uacl/config-acl-tree.ts +592 -0
- package/src/plugins/orm-plugin-uacl/index.ts +180 -0
- package/src/plugins/orm-plugin-uacl/tree.ts +331 -0
- package/src/sql-ddl-sync/Dialects/dm.ts +493 -0
- package/{lib/sql-query/Dialects/index.d.ts → src/sql-ddl-sync/Dialects/index.ts} +3 -3
- package/src/sql-ddl-sync/Dialects/mssql.ts +441 -0
- package/src/sql-ddl-sync/Dialects/mysql.ts +414 -0
- package/src/sql-ddl-sync/Dialects/postgresql.ts +474 -0
- package/src/sql-ddl-sync/Dialects/sqlite.ts +439 -0
- package/src/sql-ddl-sync/SQL.ts +157 -0
- package/src/sql-ddl-sync/Typo/Collection.d.ts +19 -0
- package/src/sql-ddl-sync/Typo/DbIndex.d.ts +11 -0
- package/{lib → src}/sql-ddl-sync/Typo/Dialect.d.ts +67 -52
- package/src/sql-ddl-sync/Typo/Driver.d.ts +67 -0
- package/src/sql-ddl-sync/Typo/Query.d.ts +8 -0
- package/src/sql-ddl-sync/Typo/SQL.d.ts +45 -0
- package/src/sql-ddl-sync/Typo/_common.d.ts +59 -0
- package/src/sql-ddl-sync/Utils.ts +291 -0
- package/src/sql-ddl-sync/index.ts +599 -0
- package/src/sql-query/Comparators.ts +115 -0
- package/src/sql-query/Create.ts +87 -0
- package/{lib/sql-query/Dialects/dm.js → src/sql-query/Dialects/dm.ts} +42 -22
- package/src/sql-query/Dialects/index.ts +14 -0
- package/src/sql-query/Dialects/mssql.ts +91 -0
- package/src/sql-query/Dialects/mysql.ts +120 -0
- package/src/sql-query/Dialects/postgresql.ts +99 -0
- package/src/sql-query/Dialects/sqlite.ts +80 -0
- package/src/sql-query/Helpers.ts +303 -0
- package/src/sql-query/Insert.ts +41 -0
- package/src/sql-query/Query.ts +140 -0
- package/src/sql-query/Remove.ts +111 -0
- package/src/sql-query/Select.ts +719 -0
- package/src/sql-query/Set.ts +25 -0
- package/src/sql-query/Typo/Aggregation.d.ts +34 -0
- package/src/sql-query/Typo/Comparators.d.ts +156 -0
- package/src/sql-query/Typo/Dialect.d.ts +51 -0
- package/src/sql-query/Typo/Field.d.ts +10 -0
- package/src/sql-query/Typo/Helper.d.ts +4 -0
- package/src/sql-query/Typo/Query-ChainBuilder.d.ts +110 -0
- package/src/sql-query/Typo/Query.d.ts +65 -0
- package/src/sql-query/Typo/Sql.d.ts +192 -0
- package/src/sql-query/Typo/SubQuery.d.ts +52 -0
- package/{lib/sql-query/Typo/index.d.ts → src/sql-query/Typo/index.ts} +5 -2
- package/src/sql-query/Update.ts +50 -0
- package/src/sql-query/Where.ts +435 -0
- package/{lib/orm/Patch → src/typings}/fib-cache.d.ts +4 -2
- package/lib/cli/commands/ddlFrom.d.ts +0 -2
- package/lib/cli/commands/dumpModel.d.ts +0 -2
- package/lib/cli/commands/escape.d.ts +0 -2
- package/lib/cli/commands/spinner.d.ts +0 -2
- package/lib/cli/commands/upgrade.d.ts +0 -2
- package/lib/cli/helpers/ddl.d.ts +0 -17
- package/lib/cli/helpers/ddl.js +0 -55
- package/lib/cli/helpers/package.d.ts +0 -25
- package/lib/cli/helpers/package.js +0 -56
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -19
- package/lib/db-driver/Typo.d.ts +0 -111
- package/lib/db-driver/Typo.js +0 -2
- package/lib/db-driver/built-ins/base.class.d.ts +0 -91
- package/lib/db-driver/built-ins/base.class.js +0 -187
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-dm.js +0 -54
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -23
- package/lib/db-driver/built-ins/driver-mongodb.js +0 -47
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-mysql.js +0 -38
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -21
- package/lib/db-driver/built-ins/driver-postgresql.js +0 -77
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -11
- package/lib/db-driver/built-ins/driver-redis.js +0 -36
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -16
- package/lib/db-driver/built-ins/driver-sqlite.js +0 -35
- package/lib/db-driver/index.d.ts +0 -3
- package/lib/db-driver/index.js +0 -5
- package/lib/db-driver/utils.d.ts +0 -14
- package/lib/db-driver/utils.js +0 -187
- package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +0 -12
- package/lib/knex/deps/tarn/dist/PendingOperation.js +0 -48
- package/lib/knex/deps/tarn/dist/Pool.d.ts +0 -97
- package/lib/knex/deps/tarn/dist/Pool.js +0 -516
- package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +0 -16
- package/lib/knex/deps/tarn/dist/PromiseInspection.js +0 -21
- package/lib/knex/deps/tarn/dist/Resource.d.ts +0 -9
- package/lib/knex/deps/tarn/dist/Resource.js +0 -19
- package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +0 -2
- package/lib/knex/deps/tarn/dist/TimeoutError.js +0 -5
- package/lib/knex/deps/tarn/dist/tarn.d.ts +0 -3
- package/lib/knex/deps/tarn/dist/tarn.js +0 -10
- package/lib/knex/deps/tarn/dist/utils.d.ts +0 -14
- package/lib/knex/deps/tarn/dist/utils.js +0 -60
- package/lib/knex/knex.d.ts +0 -2
- package/lib/knex/knex.js +0 -4
- package/lib/knex/sandbox.d.ts +0 -4
- package/lib/knex/sandbox.js +0 -23
- package/lib/orm/Adapters.d.ts +0 -3
- package/lib/orm/Adapters.js +0 -44
- package/lib/orm/AggregateFunctions.d.ts +0 -3
- package/lib/orm/AggregateFunctions.js +0 -177
- package/lib/orm/Associations/Extend.d.ts +0 -22
- package/lib/orm/Associations/Extend.js +0 -274
- package/lib/orm/Associations/Many.d.ts +0 -16
- package/lib/orm/Associations/Many.js +0 -569
- package/lib/orm/Associations/One.d.ts +0 -16
- package/lib/orm/Associations/One.js +0 -310
- package/lib/orm/Associations/_utils.d.ts +0 -14
- package/lib/orm/Associations/_utils.js +0 -53
- package/lib/orm/ChainFind.d.ts +0 -3
- package/lib/orm/ChainFind.js +0 -328
- package/lib/orm/ChainInstance.d.ts +0 -6
- package/lib/orm/ChainInstance.js +0 -74
- package/lib/orm/Debug.d.ts +0 -2
- package/lib/orm/Debug.js +0 -17
- package/lib/orm/Drivers/DB/base.d.ts +0 -2
- package/lib/orm/Drivers/DB/base.js +0 -4
- package/lib/orm/Drivers/DB/dm.d.ts +0 -9
- package/lib/orm/Drivers/DB/dm.js +0 -24
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -9
- package/lib/orm/Drivers/DB/mysql.js +0 -24
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -9
- package/lib/orm/Drivers/DB/postgres.js +0 -23
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -14
- package/lib/orm/Drivers/DB/sqlite3.js +0 -40
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
- package/lib/orm/Drivers/DML/_ddl-sql.js +0 -52
- package/lib/orm/Drivers/DML/_dml-helpers.d.ts +0 -19
- package/lib/orm/Drivers/DML/_dml-helpers.js +0 -51
- package/lib/orm/Drivers/DML/_shared.d.ts +0 -9
- package/lib/orm/Drivers/DML/_shared.js +0 -39
- package/lib/orm/Drivers/DML/_utils.d.ts +0 -8
- package/lib/orm/Drivers/DML/_utils.js +0 -67
- package/lib/orm/Drivers/DML/constants.d.ts +0 -3
- package/lib/orm/Drivers/DML/constants.js +0 -3
- package/lib/orm/Drivers/DML/dm.d.ts +0 -2
- package/lib/orm/Drivers/DML/index.d.ts +0 -4
- package/lib/orm/Drivers/DML/index.js +0 -7
- package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DML/mysql.js +0 -252
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -2
- package/lib/orm/Drivers/DML/postgres.js +0 -277
- package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
- package/lib/orm/Drivers/DML/sqlite.js +0 -267
- package/lib/orm/Error.d.ts +0 -11
- package/lib/orm/Error.js +0 -41
- package/lib/orm/Helpers.d.ts +0 -35
- package/lib/orm/Helpers.js +0 -234
- package/lib/orm/Hook.d.ts +0 -13
- package/lib/orm/Hook.js +0 -100
- package/lib/orm/Instance.d.ts +0 -2
- package/lib/orm/Instance.js +0 -698
- package/lib/orm/LazyLoad.d.ts +0 -4
- package/lib/orm/LazyLoad.js +0 -76
- package/lib/orm/Model.d.ts +0 -6
- package/lib/orm/Model.js +0 -974
- package/lib/orm/ORM.d.ts +0 -37
- package/lib/orm/ORM.js +0 -242
- package/lib/orm/Patch/fib-cache.js +0 -2
- package/lib/orm/Patch/plugin.d.ts +0 -4
- package/lib/orm/Patch/plugin.js +0 -14
- package/lib/orm/Property.d.ts +0 -9
- package/lib/orm/Property.js +0 -71
- package/lib/orm/Settings.d.ts +0 -42
- package/lib/orm/Settings.js +0 -120
- package/lib/orm/Singleton.d.ts +0 -5
- package/lib/orm/Singleton.js +0 -73
- package/lib/orm/Typo/Adapter.d.ts +0 -5
- package/lib/orm/Typo/Adapter.js +0 -2
- package/lib/orm/Typo/DMLDriver.d.ts +0 -209
- package/lib/orm/Typo/DMLDriver.js +0 -2
- package/lib/orm/Typo/Db.d.ts +0 -35
- package/lib/orm/Typo/Db.js +0 -2
- package/lib/orm/Typo/Error.d.ts +0 -29
- package/lib/orm/Typo/Error.js +0 -2
- package/lib/orm/Typo/ORM.d.ts +0 -231
- package/lib/orm/Typo/ORM.js +0 -4
- package/lib/orm/Typo/Validators.d.ts +0 -31
- package/lib/orm/Typo/Validators.js +0 -3
- package/lib/orm/Typo/_common.d.ts +0 -37
- package/lib/orm/Typo/_common.js +0 -2
- package/lib/orm/Typo/assoc.d.ts +0 -221
- package/lib/orm/Typo/assoc.js +0 -2
- package/lib/orm/Typo/hook.d.ts +0 -42
- package/lib/orm/Typo/hook.js +0 -2
- package/lib/orm/Typo/instance.d.ts +0 -156
- package/lib/orm/Typo/instance.js +0 -2
- package/lib/orm/Typo/model.js +0 -7
- package/lib/orm/Typo/patch.d.ts +0 -31
- package/lib/orm/Typo/patch.js +0 -2
- package/lib/orm/Typo/property.d.ts +0 -57
- package/lib/orm/Typo/property.js +0 -2
- package/lib/orm/Typo/query.d.ts +0 -216
- package/lib/orm/Typo/query.js +0 -2
- package/lib/orm/Typo/settings.js +0 -6
- package/lib/orm/Typo/synchronous.js +0 -2
- package/lib/orm/Utilities.d.ts +0 -178
- package/lib/orm/Utilities.js +0 -975
- package/lib/orm/Validators.d.ts +0 -33
- package/lib/orm/Validators.js +0 -101
- package/lib/orm/Where/common.d.ts +0 -1
- package/lib/orm/Where/common.js +0 -7
- package/lib/orm/Where/filterDate.d.ts +0 -11
- package/lib/orm/Where/filterDate.js +0 -58
- package/lib/orm/index.d.ts +0 -67
- package/lib/orm/index.js +0 -158
- package/lib/orm-core/callback.d.ts +0 -12
- package/lib/orm-core/callback.js +0 -2
- package/lib/orm-core/dialect.js +0 -2
- package/lib/orm-core/error.d.ts +0 -16
- package/lib/orm-core/error.js +0 -29
- package/lib/orm-core/index.js +0 -7
- package/lib/orm-core/sync.d.ts +0 -12
- package/lib/orm-core/sync.js +0 -2
- package/lib/orm-core/utils.d.ts +0 -1
- package/lib/orm-core/utils.js +0 -6
- package/lib/orm-property/Property.d.ts +0 -78
- package/lib/orm-property/Property.js +0 -2
- package/lib/orm-property/Utils.d.ts +0 -9
- package/lib/orm-property/Utils.js +0 -13
- package/lib/orm-property/customTypes.d.ts +0 -2
- package/lib/orm-property/customTypes.js +0 -13
- package/lib/orm-property/index.d.ts +0 -10
- package/lib/orm-property/index.js +0 -23
- package/lib/orm-property/transformer.d.ts +0 -5
- package/lib/orm-property/transformer.js +0 -10
- package/lib/orm-property/transformers/dm.d.ts +0 -29
- package/lib/orm-property/transformers/index.d.ts +0 -4
- package/lib/orm-property/transformers/index.js +0 -6
- package/lib/orm-property/transformers/mysql.d.ts +0 -101
- package/lib/orm-property/transformers/mysql.js +0 -262
- package/lib/orm-property/transformers/postgresql.d.ts +0 -54
- package/lib/orm-property/transformers/postgresql.js +0 -190
- package/lib/orm-property/transformers/sqlite.d.ts +0 -19
- package/lib/orm-property/transformers/sqlite.js +0 -172
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/dm.js +0 -297
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -6
- package/lib/sql-ddl-sync/Dialects/index.js +0 -8
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -38
- package/lib/sql-ddl-sync/Dialects/mysql.js +0 -241
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -287
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -43
- package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -257
- package/lib/sql-ddl-sync/SQL.d.ts +0 -12
- package/lib/sql-ddl-sync/SQL.js +0 -108
- package/lib/sql-ddl-sync/Typo/Collection.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/Collection.js +0 -2
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -2
- package/lib/sql-ddl-sync/Typo/Dialect.js +0 -2
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
- package/lib/sql-ddl-sync/Typo/Driver.js +0 -2
- package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
- package/lib/sql-ddl-sync/Typo/Query.js +0 -2
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
- package/lib/sql-ddl-sync/Typo/SQL.js +0 -2
- package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
- package/lib/sql-ddl-sync/Typo/_common.js +0 -2
- package/lib/sql-ddl-sync/Utils.d.ts +0 -39
- package/lib/sql-ddl-sync/Utils.js +0 -217
- package/lib/sql-ddl-sync/index.d.ts +0 -87
- package/lib/sql-ddl-sync/index.js +0 -372
- package/lib/sql-query/Comparators.d.ts +0 -3
- package/lib/sql-query/Comparators.js +0 -95
- package/lib/sql-query/Create.d.ts +0 -35
- package/lib/sql-query/Create.js +0 -78
- package/lib/sql-query/Dialects/dm.d.ts +0 -3
- package/lib/sql-query/Dialects/index.js +0 -13
- package/lib/sql-query/Dialects/mssql.d.ts +0 -3
- package/lib/sql-query/Dialects/mssql.js +0 -74
- package/lib/sql-query/Dialects/mysql.d.ts +0 -3
- package/lib/sql-query/Dialects/mysql.js +0 -101
- package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
- package/lib/sql-query/Dialects/postgresql.js +0 -77
- package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
- package/lib/sql-query/Dialects/sqlite.js +0 -62
- package/lib/sql-query/Helpers.d.ts +0 -37
- package/lib/sql-query/Helpers.js +0 -260
- package/lib/sql-query/Insert.d.ts +0 -12
- package/lib/sql-query/Insert.js +0 -34
- package/lib/sql-query/Query.d.ts +0 -28
- package/lib/sql-query/Query.js +0 -120
- package/lib/sql-query/Remove.d.ts +0 -16
- package/lib/sql-query/Remove.js +0 -94
- package/lib/sql-query/Select.d.ts +0 -62
- package/lib/sql-query/Select.js +0 -534
- package/lib/sql-query/Set.d.ts +0 -4
- package/lib/sql-query/Set.js +0 -16
- package/lib/sql-query/Typo/Aggregation.d.ts +0 -32
- package/lib/sql-query/Typo/Aggregation.js +0 -2
- package/lib/sql-query/Typo/Comparators.d.ts +0 -140
- package/lib/sql-query/Typo/Comparators.js +0 -2
- package/lib/sql-query/Typo/Dialect.d.ts +0 -39
- package/lib/sql-query/Typo/Dialect.js +0 -2
- package/lib/sql-query/Typo/Field.d.ts +0 -8
- package/lib/sql-query/Typo/Field.js +0 -2
- package/lib/sql-query/Typo/Helper.d.ts +0 -4
- package/lib/sql-query/Typo/Helper.js +0 -2
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
- package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -2
- package/lib/sql-query/Typo/Query.d.ts +0 -34
- package/lib/sql-query/Typo/Query.js +0 -17
- package/lib/sql-query/Typo/Sql.d.ts +0 -143
- package/lib/sql-query/Typo/Sql.js +0 -2
- package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
- package/lib/sql-query/Typo/SubQuery.js +0 -2
- package/lib/sql-query/Typo/index.js +0 -2
- package/lib/sql-query/Update.d.ts +0 -15
- package/lib/sql-query/Update.js +0 -39
- package/lib/sql-query/Where.d.ts +0 -4
- package/lib/sql-query/Where.js +0 -280
- /package/{lib → src}/codepoints-map.json +0 -0
package/lib/orm/ChainFind.js
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const util = require("util");
|
|
3
|
-
const Utilities = require("./Utilities");
|
|
4
|
-
const ChainInstance = require("./ChainInstance");
|
|
5
|
-
const _dml_helpers_1 = require("./Drivers/DML/_dml-helpers");
|
|
6
|
-
const MODEL_FUNCS = [
|
|
7
|
-
"hasOne", "hasMany",
|
|
8
|
-
"drop", "sync", "get", "clear", "create",
|
|
9
|
-
"exists", "settings", "aggregate"
|
|
10
|
-
];
|
|
11
|
-
const ChainFind = function (Model, opts) {
|
|
12
|
-
const merges = opts.merge = Utilities.combineMergeInfoToArray(opts.merge);
|
|
13
|
-
const chainRunSync = function () {
|
|
14
|
-
let conditions = util.omit(opts.conditions, Model.virtualProperties);
|
|
15
|
-
conditions = Utilities.transformPropertyNames(conditions, opts.properties);
|
|
16
|
-
Utilities.filterWhereConditionsInput(conditions, { properties: Model.allProperties });
|
|
17
|
-
const order = Utilities.transformOrderPropertyNames(opts.order, opts.properties);
|
|
18
|
-
let foundItems;
|
|
19
|
-
const vFields = Object.entries(Model.virtualProperties).map(([k, p]) => p.mapsTo || k);
|
|
20
|
-
const { tableConditions, topConditions } = Utilities.extractSelectTopConditions(conditions, vFields);
|
|
21
|
-
const __pointTypeMapsTo = (0, _dml_helpers_1.pickPointTypeFields)(opts.driver, Model.allProperties);
|
|
22
|
-
foundItems = opts.driver.find(opts.only, opts.table, tableConditions, {
|
|
23
|
-
limit: Utilities.coercePositiveInt(opts.limit, undefined),
|
|
24
|
-
order: order,
|
|
25
|
-
merge: merges,
|
|
26
|
-
offset: Utilities.coercePositiveInt(opts.offset, undefined),
|
|
27
|
-
exists: opts.exists.map(existCond => {
|
|
28
|
-
var _a;
|
|
29
|
-
const maybeAssoc = (_a = Object.values(Model.associations).find(({ association }) => association.mergeTable === existCond.table)) === null || _a === void 0 ? void 0 : _a.association;
|
|
30
|
-
const mergeProps = (maybeAssoc === null || maybeAssoc === void 0 ? void 0 : maybeAssoc.props) || null;
|
|
31
|
-
if (mergeProps) {
|
|
32
|
-
existCond.conditions = util.omit(existCond.conditions, vFields);
|
|
33
|
-
existCond.conditions = Utilities.transformPropertyNames(existCond.conditions, mergeProps);
|
|
34
|
-
Utilities.filterWhereConditionsInput(existCond.conditions, { properties: mergeProps });
|
|
35
|
-
}
|
|
36
|
-
return existCond;
|
|
37
|
-
}),
|
|
38
|
-
topConditions,
|
|
39
|
-
selectVirtualFields: vFields,
|
|
40
|
-
generateSqlSelect: opts.generateSqlSelect,
|
|
41
|
-
__pointTypeMapsTo
|
|
42
|
-
});
|
|
43
|
-
if (foundItems.length === 0) {
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* only valid for related table based on single foreign key
|
|
48
|
-
* @param err
|
|
49
|
-
* @param items
|
|
50
|
-
*/
|
|
51
|
-
const eagerLoadSync = function (items) {
|
|
52
|
-
const associationKey_Item_Map = {};
|
|
53
|
-
const self_key_field = opts.keys[0];
|
|
54
|
-
const keys = items.map(function (item) {
|
|
55
|
-
const key = item[self_key_field];
|
|
56
|
-
associationKey_Item_Map[key] = item;
|
|
57
|
-
return key;
|
|
58
|
-
});
|
|
59
|
-
Utilities.parallelQueryIfPossible(false, opts.__eager, (association) => {
|
|
60
|
-
let instances = [];
|
|
61
|
-
instances = opts.driver.eagerQuery(association, opts, keys);
|
|
62
|
-
const association_name = association.name;
|
|
63
|
-
for (let idx = 0, instance, item = null; instance = instances[idx]; idx++) {
|
|
64
|
-
item = associationKey_Item_Map[instance.$p];
|
|
65
|
-
// Create the association arrays
|
|
66
|
-
if (!item[association_name])
|
|
67
|
-
item[association_name] = [];
|
|
68
|
-
item[association_name].push(instance);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
const items = foundItems.map((dataItem) => {
|
|
73
|
-
const newInstanceSync = opts.newInstanceSync;
|
|
74
|
-
return newInstanceSync(dataItem);
|
|
75
|
-
});
|
|
76
|
-
if (opts.__eager && opts.__eager.length)
|
|
77
|
-
eagerLoadSync(items);
|
|
78
|
-
return items;
|
|
79
|
-
};
|
|
80
|
-
const chainRun = function (done) {
|
|
81
|
-
const syncResponse = Utilities.catchBlocking(chainRunSync);
|
|
82
|
-
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: done, use_tick: true });
|
|
83
|
-
};
|
|
84
|
-
const chain = {
|
|
85
|
-
model: null,
|
|
86
|
-
options: null,
|
|
87
|
-
whereExists: function () {
|
|
88
|
-
if (arguments.length && Array.isArray(arguments[0])) {
|
|
89
|
-
opts.exists = arguments[0];
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
opts.exists = Array.prototype.slice.apply(arguments);
|
|
93
|
-
}
|
|
94
|
-
return this;
|
|
95
|
-
},
|
|
96
|
-
only: function () {
|
|
97
|
-
if (arguments.length && Array.isArray(arguments[0])) {
|
|
98
|
-
opts.only = arguments[0];
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
opts.only = Array.prototype.slice.apply(arguments);
|
|
102
|
-
}
|
|
103
|
-
return this;
|
|
104
|
-
},
|
|
105
|
-
omit: function () {
|
|
106
|
-
let omit = null;
|
|
107
|
-
if (arguments.length && Array.isArray(arguments[0])) {
|
|
108
|
-
omit = arguments[0];
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
omit = Array.prototype.slice.apply(arguments);
|
|
112
|
-
}
|
|
113
|
-
this.only(util.difference(Object.keys(opts.properties), omit));
|
|
114
|
-
return this;
|
|
115
|
-
},
|
|
116
|
-
limit: function (limit) {
|
|
117
|
-
opts.limit = limit;
|
|
118
|
-
return this;
|
|
119
|
-
},
|
|
120
|
-
skip: function (offset) {
|
|
121
|
-
return this.offset(offset);
|
|
122
|
-
},
|
|
123
|
-
offset: function (offset) {
|
|
124
|
-
opts.offset = offset;
|
|
125
|
-
return this;
|
|
126
|
-
},
|
|
127
|
-
order: function (...orders) {
|
|
128
|
-
if (!Array.isArray(opts.order)) {
|
|
129
|
-
opts.order = [];
|
|
130
|
-
}
|
|
131
|
-
opts.order = opts.order.concat(Utilities.standardizeOrder(orders));
|
|
132
|
-
return this;
|
|
133
|
-
},
|
|
134
|
-
orderRaw: function (str, args) {
|
|
135
|
-
if (!Array.isArray(opts.order)) {
|
|
136
|
-
opts.order = [];
|
|
137
|
-
}
|
|
138
|
-
args = args || [];
|
|
139
|
-
opts.order.push([str, args]);
|
|
140
|
-
return this;
|
|
141
|
-
},
|
|
142
|
-
eager: function () {
|
|
143
|
-
// This will allow params such as ("abc", "def") or (["abc", "def"])
|
|
144
|
-
var associations = util.flatten(arguments);
|
|
145
|
-
// TODO: Implement eager loading for Mongo and delete this.
|
|
146
|
-
if (opts.driver.config.protocol == "mongodb:") {
|
|
147
|
-
throw new Error("MongoDB does not currently support eager loading");
|
|
148
|
-
}
|
|
149
|
-
opts.__eager = opts.associations.filter(function (association) {
|
|
150
|
-
return ~associations.indexOf(association.name);
|
|
151
|
-
});
|
|
152
|
-
return this;
|
|
153
|
-
},
|
|
154
|
-
/* methods to ChainInstance :start */
|
|
155
|
-
each: function (cb) {
|
|
156
|
-
return ChainInstance(this, cb);
|
|
157
|
-
},
|
|
158
|
-
/* methods to ChainInstance :end */
|
|
159
|
-
/* sync, callback-as-run style methods :start */
|
|
160
|
-
all: null,
|
|
161
|
-
allSync: null,
|
|
162
|
-
where: null,
|
|
163
|
-
whereSync: null,
|
|
164
|
-
find: function (...args) {
|
|
165
|
-
var cb = null;
|
|
166
|
-
opts.conditions = opts.conditions || {};
|
|
167
|
-
if (typeof util.last(args) === "function") {
|
|
168
|
-
cb = args.pop();
|
|
169
|
-
}
|
|
170
|
-
if (typeof args[0] === "object") {
|
|
171
|
-
util.extend(opts.conditions, args[0]);
|
|
172
|
-
}
|
|
173
|
-
else if (typeof args[0] === "string") {
|
|
174
|
-
opts.conditions.__sql = (opts.conditions.__sql || []);
|
|
175
|
-
opts.conditions.__sql.push(args);
|
|
176
|
-
}
|
|
177
|
-
if (cb) {
|
|
178
|
-
chainRun(cb);
|
|
179
|
-
}
|
|
180
|
-
return this;
|
|
181
|
-
},
|
|
182
|
-
findSync: function (...args) {
|
|
183
|
-
opts.conditions = opts.conditions || {};
|
|
184
|
-
if (typeof args[0] === "object") {
|
|
185
|
-
util.extend(opts.conditions, args[0]);
|
|
186
|
-
}
|
|
187
|
-
else if (typeof args[0] === "string") {
|
|
188
|
-
opts.conditions.__sql = (opts.conditions.__sql || []);
|
|
189
|
-
opts.conditions.__sql.push(args);
|
|
190
|
-
}
|
|
191
|
-
return chainRunSync();
|
|
192
|
-
},
|
|
193
|
-
count: function (cb) {
|
|
194
|
-
process.nextTick(() => {
|
|
195
|
-
const syncResult = Utilities.catchBlocking(chain.countSync);
|
|
196
|
-
Utilities.takeAwayResult(syncResult, { callback: cb });
|
|
197
|
-
});
|
|
198
|
-
return this;
|
|
199
|
-
},
|
|
200
|
-
countSync: function () {
|
|
201
|
-
const data = opts.driver.count(opts.table, Utilities.transformPropertyNames(opts.conditions, opts.properties), {
|
|
202
|
-
merge: merges
|
|
203
|
-
});
|
|
204
|
-
if (data.length === 0)
|
|
205
|
-
return 0;
|
|
206
|
-
return data[0].c;
|
|
207
|
-
},
|
|
208
|
-
remove: function (cb) {
|
|
209
|
-
process.nextTick(() => {
|
|
210
|
-
const syncResult = Utilities.catchBlocking(chain.removeSync);
|
|
211
|
-
Utilities.takeAwayResult(syncResult, { callback: cb });
|
|
212
|
-
});
|
|
213
|
-
return this;
|
|
214
|
-
},
|
|
215
|
-
// TODO: add test case about `.removeSync()`
|
|
216
|
-
removeSync: function () {
|
|
217
|
-
Utilities.disAllowOpForVModel(Model, 'modelChain.remove');
|
|
218
|
-
const keys = opts.keyProperties.map((x) => x.mapsTo);
|
|
219
|
-
const data = opts.driver.find(keys, opts.table, Utilities.transformPropertyNames(opts.conditions, opts.properties), {
|
|
220
|
-
limit: opts.limit,
|
|
221
|
-
order: Utilities.transformOrderPropertyNames(opts.order, opts.properties),
|
|
222
|
-
merge: merges,
|
|
223
|
-
offset: opts.offset,
|
|
224
|
-
exists: opts.exists,
|
|
225
|
-
__pointTypeMapsTo: [],
|
|
226
|
-
});
|
|
227
|
-
if (data.length === 0) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
const conditions = {};
|
|
231
|
-
let or;
|
|
232
|
-
conditions.or = [];
|
|
233
|
-
for (let i = 0; i < data.length; i++) {
|
|
234
|
-
or = {};
|
|
235
|
-
for (let j = 0; j < keys.length; j++) {
|
|
236
|
-
or[keys[j]] = data[i][keys[j]];
|
|
237
|
-
}
|
|
238
|
-
conditions.or.push(or);
|
|
239
|
-
}
|
|
240
|
-
return opts.driver.remove(opts.table, conditions);
|
|
241
|
-
},
|
|
242
|
-
first: function (cb) {
|
|
243
|
-
return this.run(function (err, items) {
|
|
244
|
-
return cb(err, items && items.length > 0 ? items[0] : null);
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
firstSync: function () {
|
|
248
|
-
const items = this.runSync();
|
|
249
|
-
return items && items.length > 0 ? items[0] : null;
|
|
250
|
-
},
|
|
251
|
-
last: function (cb) {
|
|
252
|
-
return this.run(function (err, items) {
|
|
253
|
-
return cb(err, items && items.length > 0 ? items[items.length - 1] : null);
|
|
254
|
-
});
|
|
255
|
-
},
|
|
256
|
-
lastSync: function () {
|
|
257
|
-
const items = this.runSync();
|
|
258
|
-
return items && items.length > 0 ? items[items.length - 1] : null;
|
|
259
|
-
},
|
|
260
|
-
run: function (cb) {
|
|
261
|
-
chainRun(cb);
|
|
262
|
-
return this;
|
|
263
|
-
},
|
|
264
|
-
runSync: function () {
|
|
265
|
-
return chainRunSync();
|
|
266
|
-
},
|
|
267
|
-
/* sync, callback-as-run style methods :end */
|
|
268
|
-
};
|
|
269
|
-
chain.allSync = chain.whereSync = chain.findSync;
|
|
270
|
-
chain.all = chain.where = chain.find;
|
|
271
|
-
if (opts.associations) {
|
|
272
|
-
for (let i = 0; i < opts.associations.length; i++) {
|
|
273
|
-
addChainMethod(chain, opts.associations[i], opts);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
for (let k in Model) {
|
|
277
|
-
if (MODEL_FUNCS.indexOf(k) >= 0) {
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
if (typeof Model[k] !== "function" || chain[k]) {
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
chain[k] = Model[k];
|
|
284
|
-
}
|
|
285
|
-
chain.model = Model;
|
|
286
|
-
chain.options = opts;
|
|
287
|
-
return chain;
|
|
288
|
-
};
|
|
289
|
-
function addChainMethod(chain, association, opts) {
|
|
290
|
-
chain[association.hasAccessor] = function (value) {
|
|
291
|
-
if (!opts.exists) {
|
|
292
|
-
opts.exists = [];
|
|
293
|
-
}
|
|
294
|
-
var conditions = {};
|
|
295
|
-
var assocIds = Object.keys(association.mergeAssocId);
|
|
296
|
-
var ids = association.model.id;
|
|
297
|
-
function mergeConditions(source) {
|
|
298
|
-
for (let i = 0, cond_item; i < assocIds.length; i++) {
|
|
299
|
-
if (typeof cond_item === "undefined") {
|
|
300
|
-
conditions[assocIds[i]] = source[ids[i]];
|
|
301
|
-
}
|
|
302
|
-
else if ((cond_item = conditions[assocIds[i]])
|
|
303
|
-
&& Array.isArray(cond_item)) {
|
|
304
|
-
cond_item.push(source[ids[i]]);
|
|
305
|
-
conditions[assocIds[i]] = cond_item;
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
conditions[assocIds[i]] = [cond_item, source[ids[i]]];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if (Array.isArray(value)) {
|
|
313
|
-
for (let i = 0; i < value.length; i++) {
|
|
314
|
-
mergeConditions(value[i]);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
mergeConditions(value);
|
|
319
|
-
}
|
|
320
|
-
opts.exists.push({
|
|
321
|
-
table: association.mergeTable,
|
|
322
|
-
link: [Object.keys(association.mergeId), association.model.id],
|
|
323
|
-
conditions: conditions
|
|
324
|
-
});
|
|
325
|
-
return chain;
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
module.exports = ChainFind;
|
package/lib/orm/ChainInstance.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = function ChainInstance(chain, chain_cb) {
|
|
3
|
-
let instances = null;
|
|
4
|
-
let loading = false;
|
|
5
|
-
const queue = [];
|
|
6
|
-
const load = function () {
|
|
7
|
-
loading = true;
|
|
8
|
-
chain.run(function (err, items) {
|
|
9
|
-
instances = items;
|
|
10
|
-
return next();
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
const pushIterateeQueue = function (hwd) {
|
|
14
|
-
return function (cb) {
|
|
15
|
-
if (!loading) {
|
|
16
|
-
load();
|
|
17
|
-
}
|
|
18
|
-
queue.push({ hwd: hwd, args: [cb] });
|
|
19
|
-
return calls;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const next = function () {
|
|
23
|
-
if (queue.length === 0)
|
|
24
|
-
return;
|
|
25
|
-
const item = queue.shift();
|
|
26
|
-
return item.hwd.apply(calls, item.args);
|
|
27
|
-
};
|
|
28
|
-
const calls = {
|
|
29
|
-
_each: pushIterateeQueue(function (cb) {
|
|
30
|
-
instances.forEach(cb);
|
|
31
|
-
return next();
|
|
32
|
-
}),
|
|
33
|
-
filter: pushIterateeQueue(function (cb) {
|
|
34
|
-
instances = instances.filter(cb);
|
|
35
|
-
return next();
|
|
36
|
-
}),
|
|
37
|
-
sort: pushIterateeQueue(function (cb) {
|
|
38
|
-
instances.sort(cb);
|
|
39
|
-
return next();
|
|
40
|
-
}),
|
|
41
|
-
count: pushIterateeQueue(function (cb) {
|
|
42
|
-
cb(instances.length);
|
|
43
|
-
return next();
|
|
44
|
-
}),
|
|
45
|
-
get: pushIterateeQueue(function (cb) {
|
|
46
|
-
cb(instances);
|
|
47
|
-
return next();
|
|
48
|
-
}),
|
|
49
|
-
save: pushIterateeQueue(function (cb) {
|
|
50
|
-
const saveNext = function (i) {
|
|
51
|
-
if (i >= instances.length) {
|
|
52
|
-
if (typeof cb === "function") {
|
|
53
|
-
cb();
|
|
54
|
-
}
|
|
55
|
-
return next();
|
|
56
|
-
}
|
|
57
|
-
return instances[i].save(function (err) {
|
|
58
|
-
if (err) {
|
|
59
|
-
if (typeof cb === "function") {
|
|
60
|
-
cb(err);
|
|
61
|
-
}
|
|
62
|
-
return next();
|
|
63
|
-
}
|
|
64
|
-
return saveNext(i + 1);
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
return saveNext(0);
|
|
68
|
-
})
|
|
69
|
-
};
|
|
70
|
-
if (typeof chain_cb === "function") {
|
|
71
|
-
return calls._each(chain_cb);
|
|
72
|
-
}
|
|
73
|
-
return calls;
|
|
74
|
-
};
|
package/lib/orm/Debug.d.ts
DELETED
package/lib/orm/Debug.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sql = sql;
|
|
4
|
-
const util = require("util");
|
|
5
|
-
const tty = require("tty");
|
|
6
|
-
function sql(driver, sql) {
|
|
7
|
-
var fmt;
|
|
8
|
-
if (tty.isatty(process.stdout.fd)) {
|
|
9
|
-
fmt = "\x1b[32;1m(orm/%s) \x1b[34m%s\x1b[0m\n";
|
|
10
|
-
sql = sql.replace(/`(.+?)`/g, function (m) { return "\x1b[31m" + m + "\x1b[34m"; });
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
fmt = "[SQL/%s] %s\n";
|
|
14
|
-
}
|
|
15
|
-
process.stdout.write(util.format(fmt, driver, sql));
|
|
16
|
-
}
|
|
17
|
-
;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FxOrmCommon } from '../../Typo/_common';
|
|
2
|
-
import type { FxOrmDb } from '../../Typo/Db';
|
|
3
|
-
declare const Driver: typeof import("../../../db-driver/built-ins/driver-dm").default;
|
|
4
|
-
export declare class Database extends Driver implements FxOrmDb.Database<Class_DbConnection> {
|
|
5
|
-
eventor: Class_EventEmitter;
|
|
6
|
-
connect(cb?: FxOrmCommon.GenericCallback<Class_DbConnection>): Class_DbConnection;
|
|
7
|
-
query<T = any>(sql: string, cb?: FxOrmCommon.GenericCallback<T>): any;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
package/lib/orm/Drivers/DB/dm.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Database = void 0;
|
|
4
|
-
const index_1 = require("../../../db-driver/index");
|
|
5
|
-
const getEventEmitter = require("./base");
|
|
6
|
-
const Utilities = require("../../Utilities");
|
|
7
|
-
const Driver = index_1.Driver.getDriver('dm');
|
|
8
|
-
class Database extends Driver {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.eventor = getEventEmitter();
|
|
12
|
-
}
|
|
13
|
-
connect(cb) {
|
|
14
|
-
const exposedErrResults = Utilities.catchBlocking(() => super.open());
|
|
15
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
16
|
-
return this.connection;
|
|
17
|
-
}
|
|
18
|
-
query(sql, cb) {
|
|
19
|
-
const exposedErrResults = Utilities.catchBlocking(() => this.execute(sql));
|
|
20
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
21
|
-
return exposedErrResults.result;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.Database = Database;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FxOrmCommon } from '../../Typo/_common';
|
|
2
|
-
import type { FxOrmDb } from '../../Typo/Db';
|
|
3
|
-
declare const Driver: typeof import("../../../db-driver/built-ins/driver-mysql").default;
|
|
4
|
-
export declare class Database extends Driver implements FxOrmDb.Database<Class_MySQL> {
|
|
5
|
-
eventor: Class_EventEmitter;
|
|
6
|
-
connect(cb?: FxOrmCommon.GenericCallback<Class_MySQL>): Class_MySQL;
|
|
7
|
-
query<T = any>(sql: string, cb?: FxOrmCommon.GenericCallback<T>): any;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Database = void 0;
|
|
4
|
-
const index_1 = require("../../../db-driver/index");
|
|
5
|
-
const getEventEmitter = require("./base");
|
|
6
|
-
const Utilities = require("../../Utilities");
|
|
7
|
-
const Driver = index_1.Driver.getDriver('mysql');
|
|
8
|
-
class Database extends Driver {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.eventor = getEventEmitter();
|
|
12
|
-
}
|
|
13
|
-
connect(cb) {
|
|
14
|
-
const exposedErrResults = Utilities.catchBlocking(() => super.open());
|
|
15
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
16
|
-
return this.connection;
|
|
17
|
-
}
|
|
18
|
-
query(sql, cb) {
|
|
19
|
-
const exposedErrResults = Utilities.catchBlocking(() => this.execute(sql));
|
|
20
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
21
|
-
return exposedErrResults.result;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.Database = Database;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FxOrmCommon } from '../../Typo/_common';
|
|
2
|
-
import type { FxOrmDb } from '../../Typo/Db';
|
|
3
|
-
declare const Driver: typeof import("../../../db-driver/built-ins/driver-postgresql").default;
|
|
4
|
-
export default class PostgresqlDatabase extends Driver implements FxOrmDb.Database<Class_DbConnection> {
|
|
5
|
-
eventor: Class_EventEmitter;
|
|
6
|
-
connect(cb?: FxOrmCommon.GenericCallback<Class_DbConnection>): Class_DbConnection;
|
|
7
|
-
query<T = any>(sql: string, cb?: FxOrmCommon.GenericCallback<T>): any;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("../../../db-driver/index");
|
|
4
|
-
const getEventEmitter = require("./base");
|
|
5
|
-
const Utilities = require("../../Utilities");
|
|
6
|
-
const Driver = index_1.Driver.getDriver('postgresql');
|
|
7
|
-
class PostgresqlDatabase extends Driver {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this.eventor = getEventEmitter();
|
|
11
|
-
}
|
|
12
|
-
connect(cb) {
|
|
13
|
-
const exposedErrResults = Utilities.catchBlocking(() => super.open());
|
|
14
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
15
|
-
return this.connection;
|
|
16
|
-
}
|
|
17
|
-
query(sql, cb) {
|
|
18
|
-
const exposedErrResults = Utilities.catchBlocking(() => this.execute(sql));
|
|
19
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
20
|
-
return exposedErrResults.result;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.default = PostgresqlDatabase;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FxOrmCommon } from '../../Typo/_common';
|
|
2
|
-
import type { FxOrmDb } from '../../Typo/Db';
|
|
3
|
-
declare const Driver: typeof import("../../../db-driver/built-ins/driver-sqlite").default;
|
|
4
|
-
export declare class Database extends Driver implements FxOrmDb.DatabaseBase_SQLite {
|
|
5
|
-
eventor: Class_EventEmitter;
|
|
6
|
-
conn: Class_SQLite;
|
|
7
|
-
get use_memory(): boolean;
|
|
8
|
-
constructor(opts: any);
|
|
9
|
-
connect(cb?: FxOrmCommon.GenericCallback<Class_SQLite>): Class_SQLite;
|
|
10
|
-
query<T = any>(sql: string, cb?: FxOrmCommon.GenericCallback<T>): any;
|
|
11
|
-
all<T = any>(sql: string, cb?: FxOrmCommon.GenericCallback<T>): any;
|
|
12
|
-
get<T = any>(sql: string, cb?: FxOrmCommon.GenericCallback<T>): any;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Database = void 0;
|
|
4
|
-
const index_1 = require("../../../db-driver/index");
|
|
5
|
-
const getEventEmitter = require("./base");
|
|
6
|
-
const Utilities = require("../../Utilities");
|
|
7
|
-
function isMemoryMode(href) {
|
|
8
|
-
return href === ':memory:';
|
|
9
|
-
}
|
|
10
|
-
const Driver = index_1.Driver.getDriver('sqlite');
|
|
11
|
-
class Database extends Driver {
|
|
12
|
-
get use_memory() {
|
|
13
|
-
return isMemoryMode(this.config.href);
|
|
14
|
-
}
|
|
15
|
-
constructor(opts) {
|
|
16
|
-
super(opts);
|
|
17
|
-
this.eventor = getEventEmitter();
|
|
18
|
-
this.config.slashes = false;
|
|
19
|
-
}
|
|
20
|
-
connect(cb) {
|
|
21
|
-
const exposedErrResults = Utilities.catchBlocking(() => super.open());
|
|
22
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
23
|
-
return this.connection;
|
|
24
|
-
}
|
|
25
|
-
query(sql, cb) {
|
|
26
|
-
const exposedErrResults = Utilities.catchBlocking(() => this.execute(sql));
|
|
27
|
-
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
|
|
28
|
-
return exposedErrResults.result;
|
|
29
|
-
}
|
|
30
|
-
all(sql, cb) {
|
|
31
|
-
return this.query(sql, cb);
|
|
32
|
-
}
|
|
33
|
-
get(sql, cb) {
|
|
34
|
-
const results = this.all(sql)[0];
|
|
35
|
-
if (typeof cb === 'function')
|
|
36
|
-
return cb(null, results);
|
|
37
|
-
return results;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.Database = Database;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doDrop = exports.doSync = void 0;
|
|
4
|
-
const _merge = require("lodash.merge");
|
|
5
|
-
const index_1 = require("../../../sql-ddl-sync/index");
|
|
6
|
-
const Utilities = require("../../Utilities");
|
|
7
|
-
function setIndex(p, v, k) {
|
|
8
|
-
v.index = true;
|
|
9
|
-
p[k] = v;
|
|
10
|
-
}
|
|
11
|
-
;
|
|
12
|
-
const doSync = function (opts) {
|
|
13
|
-
const syncInstance = new index_1.Sync(Object.assign(Object.assign({}, opts.allow_drop_column && { suppressColumnDrop: false }), { dbdriver: this.db, debug: function (text) {
|
|
14
|
-
process.env.DEBUG_SQLDDLSYNC && global.console.log("> %s", text);
|
|
15
|
-
} }));
|
|
16
|
-
if (opts.repair_column)
|
|
17
|
-
syncInstance.strategy = 'mixed';
|
|
18
|
-
if (this.customTypes) {
|
|
19
|
-
for (let k in this.customTypes) {
|
|
20
|
-
syncInstance.defineType(k, this.customTypes[k]);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
syncInstance.defineCollection(opts.table, opts.allProperties, {
|
|
24
|
-
comment: opts === null || opts === void 0 ? void 0 : opts.tableComment
|
|
25
|
-
});
|
|
26
|
-
for (let i = 0, props = {}; i < opts.many_associations.length; i++) {
|
|
27
|
-
props = {};
|
|
28
|
-
_merge(props, opts.many_associations[i].mergeId);
|
|
29
|
-
_merge(props, opts.many_associations[i].mergeAssocId);
|
|
30
|
-
Object.entries(props).forEach(([k, v]) => setIndex(props, v, k));
|
|
31
|
-
_merge(props, opts.many_associations[i].props);
|
|
32
|
-
syncInstance.defineCollection(opts.many_associations[i].mergeTable, props);
|
|
33
|
-
}
|
|
34
|
-
syncInstance.sync();
|
|
35
|
-
return this;
|
|
36
|
-
};
|
|
37
|
-
exports.doSync = doSync;
|
|
38
|
-
const doDrop = function (opts) {
|
|
39
|
-
let drop_queries = [], pending, err;
|
|
40
|
-
drop_queries.push(`DROP TABLE IF EXISTS ${this.query.escapeId(opts.table)}`);
|
|
41
|
-
for (let i = 0; i < opts.many_associations.length; i++) {
|
|
42
|
-
drop_queries.push(`DROP TABLE IF EXISTS ${this.query.escapeId(opts.many_associations[i].mergeTable)}`);
|
|
43
|
-
}
|
|
44
|
-
pending = drop_queries.length;
|
|
45
|
-
for (let i = 0; i < drop_queries.length; i++) {
|
|
46
|
-
err = Utilities.catchBlocking(this.execQuery, [drop_queries[i]], { thisArg: this }).error;
|
|
47
|
-
if (err || --pending === 0)
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
return this;
|
|
51
|
-
};
|
|
52
|
-
exports.doDrop = doDrop;
|