uql-orm 0.9.3 → 0.9.5
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/CHANGELOG.md +20 -1
- package/README.md +62 -683
- package/dist/browser/uql-browser.min.js +4791 -2940
- package/dist/browser/uql-browser.min.js.map +1 -1
- package/package.json +4 -4
- package/dist/browser/http/bus.d.ts +0 -4
- package/dist/browser/http/bus.d.ts.map +0 -1
- package/dist/browser/http/bus.js +0 -14
- package/dist/browser/http/bus.js.map +0 -1
- package/dist/browser/http/http.d.ts +0 -7
- package/dist/browser/http/http.d.ts.map +0 -1
- package/dist/browser/http/http.js +0 -45
- package/dist/browser/http/http.js.map +0 -1
- package/dist/browser/http/index.d.ts +0 -3
- package/dist/browser/http/index.d.ts.map +0 -1
- package/dist/browser/http/index.js +0 -3
- package/dist/browser/http/index.js.map +0 -1
- package/dist/browser/index.d.ts +0 -5
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js +0 -5
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/options.d.ts +0 -5
- package/dist/browser/options.d.ts.map +0 -1
- package/dist/browser/options.js +0 -14
- package/dist/browser/options.js.map +0 -1
- package/dist/browser/querier/httpQuerier.d.ts +0 -20
- package/dist/browser/querier/httpQuerier.d.ts.map +0 -1
- package/dist/browser/querier/httpQuerier.js +0 -68
- package/dist/browser/querier/httpQuerier.js.map +0 -1
- package/dist/browser/querier/index.d.ts +0 -3
- package/dist/browser/querier/index.d.ts.map +0 -1
- package/dist/browser/querier/index.js +0 -3
- package/dist/browser/querier/index.js.map +0 -1
- package/dist/browser/querier/querier.util.d.ts +0 -3
- package/dist/browser/querier/querier.util.d.ts.map +0 -1
- package/dist/browser/querier/querier.util.js +0 -17
- package/dist/browser/querier/querier.util.js.map +0 -1
- package/dist/browser/type/clientQuerier.d.ts +0 -24
- package/dist/browser/type/clientQuerier.d.ts.map +0 -1
- package/dist/browser/type/clientQuerier.js +0 -2
- package/dist/browser/type/clientQuerier.js.map +0 -1
- package/dist/browser/type/clientQuerierPool.d.ts +0 -5
- package/dist/browser/type/clientQuerierPool.d.ts.map +0 -1
- package/dist/browser/type/clientQuerierPool.js +0 -2
- package/dist/browser/type/clientQuerierPool.js.map +0 -1
- package/dist/browser/type/index.d.ts +0 -4
- package/dist/browser/type/index.d.ts.map +0 -1
- package/dist/browser/type/index.js +0 -4
- package/dist/browser/type/index.js.map +0 -1
- package/dist/browser/type/request.d.ts +0 -29
- package/dist/browser/type/request.d.ts.map +0 -1
- package/dist/browser/type/request.js +0 -2
- package/dist/browser/type/request.js.map +0 -1
- package/dist/bunSql/bunSql.util.d.ts +0 -30
- package/dist/bunSql/bunSql.util.d.ts.map +0 -1
- package/dist/bunSql/bunSql.util.js +0 -101
- package/dist/bunSql/bunSql.util.js.map +0 -1
- package/dist/bunSql/bunSqlPostgresDialect.d.ts +0 -12
- package/dist/bunSql/bunSqlPostgresDialect.d.ts.map +0 -1
- package/dist/bunSql/bunSqlPostgresDialect.js +0 -21
- package/dist/bunSql/bunSqlPostgresDialect.js.map +0 -1
- package/dist/bunSql/bunSqlQuerier.d.ts +0 -14
- package/dist/bunSql/bunSqlQuerier.d.ts.map +0 -1
- package/dist/bunSql/bunSqlQuerier.js +0 -37
- package/dist/bunSql/bunSqlQuerier.js.map +0 -1
- package/dist/bunSql/bunSqlQuerierPool.d.ts +0 -19
- package/dist/bunSql/bunSqlQuerierPool.d.ts.map +0 -1
- package/dist/bunSql/bunSqlQuerierPool.js +0 -58
- package/dist/bunSql/bunSqlQuerierPool.js.map +0 -1
- package/dist/bunSql/bunSqliteDialect.d.ts +0 -7
- package/dist/bunSql/bunSqliteDialect.d.ts.map +0 -1
- package/dist/bunSql/bunSqliteDialect.js +0 -7
- package/dist/bunSql/bunSqliteDialect.js.map +0 -1
- package/dist/bunSql/index.d.ts +0 -5
- package/dist/bunSql/index.d.ts.map +0 -1
- package/dist/bunSql/index.js +0 -5
- package/dist/bunSql/index.js.map +0 -1
- package/dist/cockroachdb/cockroachDialect.d.ts +0 -15
- package/dist/cockroachdb/cockroachDialect.d.ts.map +0 -1
- package/dist/cockroachdb/cockroachDialect.js +0 -14
- package/dist/cockroachdb/cockroachDialect.js.map +0 -1
- package/dist/cockroachdb/crdbQuerier.d.ts +0 -9
- package/dist/cockroachdb/crdbQuerier.d.ts.map +0 -1
- package/dist/cockroachdb/crdbQuerier.js +0 -7
- package/dist/cockroachdb/crdbQuerier.js.map +0 -1
- package/dist/cockroachdb/crdbQuerierPool.d.ts +0 -14
- package/dist/cockroachdb/crdbQuerierPool.d.ts.map +0 -1
- package/dist/cockroachdb/crdbQuerierPool.js +0 -18
- package/dist/cockroachdb/crdbQuerierPool.js.map +0 -1
- package/dist/cockroachdb/index.d.ts +0 -4
- package/dist/cockroachdb/index.d.ts.map +0 -1
- package/dist/cockroachdb/index.js +0 -4
- package/dist/cockroachdb/index.js.map +0 -1
- package/dist/d1/d1Querier.d.ts +0 -46
- package/dist/d1/d1Querier.d.ts.map +0 -1
- package/dist/d1/d1Querier.js +0 -30
- package/dist/d1/d1Querier.js.map +0 -1
- package/dist/d1/d1QuerierPool.d.ts +0 -11
- package/dist/d1/d1QuerierPool.d.ts.map +0 -1
- package/dist/d1/d1QuerierPool.js +0 -17
- package/dist/d1/d1QuerierPool.js.map +0 -1
- package/dist/d1/d1SqliteDialect.d.ts +0 -10
- package/dist/d1/d1SqliteDialect.d.ts.map +0 -1
- package/dist/d1/d1SqliteDialect.js +0 -10
- package/dist/d1/d1SqliteDialect.js.map +0 -1
- package/dist/d1/index.d.ts +0 -4
- package/dist/d1/index.d.ts.map +0 -1
- package/dist/d1/index.js +0 -4
- package/dist/d1/index.js.map +0 -1
- package/dist/dialect/abstractDialect.d.ts +0 -32
- package/dist/dialect/abstractDialect.d.ts.map +0 -1
- package/dist/dialect/abstractDialect.js +0 -39
- package/dist/dialect/abstractDialect.js.map +0 -1
- package/dist/dialect/abstractSqlDialect.d.ts +0 -233
- package/dist/dialect/abstractSqlDialect.d.ts.map +0 -1
- package/dist/dialect/abstractSqlDialect.js +0 -1332
- package/dist/dialect/abstractSqlDialect.js.map +0 -1
- package/dist/dialect/index.d.ts +0 -9
- package/dist/dialect/index.d.ts.map +0 -1
- package/dist/dialect/index.js +0 -9
- package/dist/dialect/index.js.map +0 -1
- package/dist/dialect/jsonArrayElemMatchUtils.d.ts +0 -10
- package/dist/dialect/jsonArrayElemMatchUtils.d.ts.map +0 -1
- package/dist/dialect/jsonArrayElemMatchUtils.js +0 -24
- package/dist/dialect/jsonArrayElemMatchUtils.js.map +0 -1
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +0 -36
- package/dist/dialect/mysqlLikeSqlDialect.d.ts.map +0 -1
- package/dist/dialect/mysqlLikeSqlDialect.js +0 -84
- package/dist/dialect/mysqlLikeSqlDialect.js.map +0 -1
- package/dist/dialect/queryContext.d.ts +0 -49
- package/dist/dialect/queryContext.d.ts.map +0 -1
- package/dist/dialect/queryContext.js +0 -65
- package/dist/dialect/queryContext.js.map +0 -1
- package/dist/entity/decorator/entity.d.ts +0 -3
- package/dist/entity/decorator/entity.d.ts.map +0 -1
- package/dist/entity/decorator/entity.js +0 -7
- package/dist/entity/decorator/entity.js.map +0 -1
- package/dist/entity/decorator/field.d.ts +0 -3
- package/dist/entity/decorator/field.d.ts.map +0 -1
- package/dist/entity/decorator/field.js +0 -8
- package/dist/entity/decorator/field.js.map +0 -1
- package/dist/entity/decorator/hook.d.ts +0 -8
- package/dist/entity/decorator/hook.d.ts.map +0 -1
- package/dist/entity/decorator/hook.js +0 -15
- package/dist/entity/decorator/hook.js.map +0 -1
- package/dist/entity/decorator/id.d.ts +0 -3
- package/dist/entity/decorator/id.d.ts.map +0 -1
- package/dist/entity/decorator/id.js +0 -8
- package/dist/entity/decorator/id.js.map +0 -1
- package/dist/entity/decorator/index-decorator.d.ts +0 -37
- package/dist/entity/decorator/index-decorator.d.ts.map +0 -1
- package/dist/entity/decorator/index-decorator.js +0 -27
- package/dist/entity/decorator/index-decorator.js.map +0 -1
- package/dist/entity/decorator/index.d.ts +0 -8
- package/dist/entity/decorator/index.d.ts.map +0 -1
- package/dist/entity/decorator/index.js +0 -8
- package/dist/entity/decorator/index.js.map +0 -1
- package/dist/entity/decorator/relation.d.ts +0 -9
- package/dist/entity/decorator/relation.d.ts.map +0 -1
- package/dist/entity/decorator/relation.js +0 -20
- package/dist/entity/decorator/relation.js.map +0 -1
- package/dist/entity/index.d.ts +0 -2
- package/dist/entity/index.d.ts.map +0 -1
- package/dist/entity/index.js +0 -2
- package/dist/entity/index.js.map +0 -1
- package/dist/entity/metadata/definition.d.ts +0 -16
- package/dist/entity/metadata/definition.d.ts.map +0 -1
- package/dist/entity/metadata/definition.js +0 -309
- package/dist/entity/metadata/definition.js.map +0 -1
- package/dist/entity/test-helpers.d.ts +0 -4
- package/dist/entity/test-helpers.d.ts.map +0 -1
- package/dist/entity/test-helpers.js +0 -15
- package/dist/entity/test-helpers.js.map +0 -1
- package/dist/express/index.d.ts +0 -3
- package/dist/express/index.d.ts.map +0 -1
- package/dist/express/index.js +0 -3
- package/dist/express/index.js.map +0 -1
- package/dist/express/querierMiddleware.d.ts +0 -26
- package/dist/express/querierMiddleware.d.ts.map +0 -1
- package/dist/express/querierMiddleware.js +0 -143
- package/dist/express/querierMiddleware.js.map +0 -1
- package/dist/express/query.util.d.ts +0 -7
- package/dist/express/query.util.d.ts.map +0 -1
- package/dist/express/query.util.js +0 -27
- package/dist/express/query.util.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/libsql/index.d.ts +0 -4
- package/dist/libsql/index.d.ts.map +0 -1
- package/dist/libsql/index.js +0 -4
- package/dist/libsql/index.js.map +0 -1
- package/dist/libsql/libsqlDialect.d.ts +0 -10
- package/dist/libsql/libsqlDialect.d.ts.map +0 -1
- package/dist/libsql/libsqlDialect.js +0 -10
- package/dist/libsql/libsqlDialect.js.map +0 -1
- package/dist/libsql/libsqlQuerier.d.ts +0 -24
- package/dist/libsql/libsqlQuerier.d.ts.map +0 -1
- package/dist/libsql/libsqlQuerier.js +0 -76
- package/dist/libsql/libsqlQuerier.js.map +0 -1
- package/dist/libsql/libsqlQuerierPool.d.ts +0 -20
- package/dist/libsql/libsqlQuerierPool.d.ts.map +0 -1
- package/dist/libsql/libsqlQuerierPool.js +0 -40
- package/dist/libsql/libsqlQuerierPool.js.map +0 -1
- package/dist/maria/index.d.ts +0 -4
- package/dist/maria/index.d.ts.map +0 -1
- package/dist/maria/index.js +0 -4
- package/dist/maria/index.js.map +0 -1
- package/dist/maria/mariaDialect.d.ts +0 -16
- package/dist/maria/mariaDialect.d.ts.map +0 -1
- package/dist/maria/mariaDialect.js +0 -56
- package/dist/maria/mariaDialect.js.map +0 -1
- package/dist/maria/mariadbQuerier.d.ts +0 -12
- package/dist/maria/mariadbQuerier.d.ts.map +0 -1
- package/dist/maria/mariadbQuerier.js +0 -31
- package/dist/maria/mariadbQuerier.js.map +0 -1
- package/dist/maria/mariadbQuerierPool.d.ts +0 -14
- package/dist/maria/mariadbQuerierPool.d.ts.map +0 -1
- package/dist/maria/mariadbQuerierPool.js +0 -18
- package/dist/maria/mariadbQuerierPool.js.map +0 -1
- package/dist/migrate/acquireQuerierForMigrations.d.ts +0 -9
- package/dist/migrate/acquireQuerierForMigrations.d.ts.map +0 -1
- package/dist/migrate/acquireQuerierForMigrations.js +0 -10
- package/dist/migrate/acquireQuerierForMigrations.js.map +0 -1
- package/dist/migrate/assertCliConfig.d.ts +0 -6
- package/dist/migrate/assertCliConfig.d.ts.map +0 -1
- package/dist/migrate/assertCliConfig.js +0 -31
- package/dist/migrate/assertCliConfig.js.map +0 -1
- package/dist/migrate/bin.d.ts +0 -3
- package/dist/migrate/bin.d.ts.map +0 -1
- package/dist/migrate/bin.js +0 -7
- package/dist/migrate/bin.js.map +0 -1
- package/dist/migrate/builder/columnBuilder.d.ts +0 -79
- package/dist/migrate/builder/columnBuilder.d.ts.map +0 -1
- package/dist/migrate/builder/columnBuilder.js +0 -159
- package/dist/migrate/builder/columnBuilder.js.map +0 -1
- package/dist/migrate/builder/expressions.d.ts +0 -87
- package/dist/migrate/builder/expressions.d.ts.map +0 -1
- package/dist/migrate/builder/expressions.js +0 -150
- package/dist/migrate/builder/expressions.js.map +0 -1
- package/dist/migrate/builder/index.d.ts +0 -6
- package/dist/migrate/builder/index.d.ts.map +0 -1
- package/dist/migrate/builder/index.js +0 -6
- package/dist/migrate/builder/index.js.map +0 -1
- package/dist/migrate/builder/migrationBuilder.d.ts +0 -110
- package/dist/migrate/builder/migrationBuilder.d.ts.map +0 -1
- package/dist/migrate/builder/migrationBuilder.js +0 -470
- package/dist/migrate/builder/migrationBuilder.js.map +0 -1
- package/dist/migrate/builder/splitSqlStatements.d.ts +0 -18
- package/dist/migrate/builder/splitSqlStatements.d.ts.map +0 -1
- package/dist/migrate/builder/splitSqlStatements.js +0 -44
- package/dist/migrate/builder/splitSqlStatements.js.map +0 -1
- package/dist/migrate/builder/tableBuilder.d.ts +0 -51
- package/dist/migrate/builder/tableBuilder.d.ts.map +0 -1
- package/dist/migrate/builder/tableBuilder.js +0 -291
- package/dist/migrate/builder/tableBuilder.js.map +0 -1
- package/dist/migrate/builder/types.d.ts +0 -466
- package/dist/migrate/builder/types.d.ts.map +0 -1
- package/dist/migrate/builder/types.js +0 -8
- package/dist/migrate/builder/types.js.map +0 -1
- package/dist/migrate/cli-config.d.ts +0 -3
- package/dist/migrate/cli-config.d.ts.map +0 -1
- package/dist/migrate/cli-config.js +0 -35
- package/dist/migrate/cli-config.js.map +0 -1
- package/dist/migrate/cli.d.ts +0 -20
- package/dist/migrate/cli.d.ts.map +0 -1
- package/dist/migrate/cli.js +0 -398
- package/dist/migrate/cli.js.map +0 -1
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -137
- package/dist/migrate/codegen/entityCodeGenerator.d.ts.map +0 -1
- package/dist/migrate/codegen/entityCodeGenerator.js +0 -405
- package/dist/migrate/codegen/entityCodeGenerator.js.map +0 -1
- package/dist/migrate/codegen/entityMerger.d.ts +0 -115
- package/dist/migrate/codegen/entityMerger.d.ts.map +0 -1
- package/dist/migrate/codegen/entityMerger.js +0 -294
- package/dist/migrate/codegen/entityMerger.js.map +0 -1
- package/dist/migrate/codegen/index.d.ts +0 -11
- package/dist/migrate/codegen/index.d.ts.map +0 -1
- package/dist/migrate/codegen/index.js +0 -15
- package/dist/migrate/codegen/index.js.map +0 -1
- package/dist/migrate/codegen/migrationCodeGenerator.d.ts +0 -62
- package/dist/migrate/codegen/migrationCodeGenerator.d.ts.map +0 -1
- package/dist/migrate/codegen/migrationCodeGenerator.js +0 -356
- package/dist/migrate/codegen/migrationCodeGenerator.js.map +0 -1
- package/dist/migrate/codegen/migrationFile.d.ts +0 -29
- package/dist/migrate/codegen/migrationFile.d.ts.map +0 -1
- package/dist/migrate/codegen/migrationFile.js +0 -48
- package/dist/migrate/codegen/migrationFile.js.map +0 -1
- package/dist/migrate/codegen/smartRelationDetector.d.ts +0 -48
- package/dist/migrate/codegen/smartRelationDetector.d.ts.map +0 -1
- package/dist/migrate/codegen/smartRelationDetector.js +0 -135
- package/dist/migrate/codegen/smartRelationDetector.js.map +0 -1
- package/dist/migrate/drift/driftDetector.d.ts +0 -80
- package/dist/migrate/drift/driftDetector.d.ts.map +0 -1
- package/dist/migrate/drift/driftDetector.js +0 -247
- package/dist/migrate/drift/driftDetector.js.map +0 -1
- package/dist/migrate/drift/index.d.ts +0 -7
- package/dist/migrate/drift/index.d.ts.map +0 -1
- package/dist/migrate/drift/index.js +0 -7
- package/dist/migrate/drift/index.js.map +0 -1
- package/dist/migrate/generator/index.d.ts +0 -3
- package/dist/migrate/generator/index.d.ts.map +0 -1
- package/dist/migrate/generator/index.js +0 -3
- package/dist/migrate/generator/index.js.map +0 -1
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +0 -48
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts.map +0 -1
- package/dist/migrate/generator/mongoSchemaGenerator.js +0 -188
- package/dist/migrate/generator/mongoSchemaGenerator.js.map +0 -1
- package/dist/migrate/index.d.ts +0 -16
- package/dist/migrate/index.d.ts.map +0 -1
- package/dist/migrate/index.js +0 -23
- package/dist/migrate/index.js.map +0 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +0 -77
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +0 -156
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js.map +0 -1
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -26
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/baseSqlIntrospector.js +0 -132
- package/dist/migrate/introspection/baseSqlIntrospector.js.map +0 -1
- package/dist/migrate/introspection/index.d.ts +0 -6
- package/dist/migrate/introspection/index.d.ts.map +0 -1
- package/dist/migrate/introspection/index.js +0 -6
- package/dist/migrate/introspection/index.js.map +0 -1
- package/dist/migrate/introspection/mongoIntrospector.d.ts +0 -15
- package/dist/migrate/introspection/mongoIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/mongoIntrospector.js +0 -100
- package/dist/migrate/introspection/mongoIntrospector.js.map +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +0 -59
- package/dist/migrate/introspection/mysqlIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.js +0 -175
- package/dist/migrate/introspection/mysqlIntrospector.js.map +0 -1
- package/dist/migrate/introspection/postgresIntrospector.d.ts +0 -55
- package/dist/migrate/introspection/postgresIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/postgresIntrospector.js +0 -226
- package/dist/migrate/introspection/postgresIntrospector.js.map +0 -1
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +0 -60
- package/dist/migrate/introspection/sqliteIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/sqliteIntrospector.js +0 -188
- package/dist/migrate/introspection/sqliteIntrospector.js.map +0 -1
- package/dist/migrate/migrator.d.ts +0 -168
- package/dist/migrate/migrator.d.ts.map +0 -1
- package/dist/migrate/migrator.js +0 -614
- package/dist/migrate/migrator.js.map +0 -1
- package/dist/migrate/schemaGenerator.d.ts +0 -142
- package/dist/migrate/schemaGenerator.d.ts.map +0 -1
- package/dist/migrate/schemaGenerator.js +0 -693
- package/dist/migrate/schemaGenerator.js.map +0 -1
- package/dist/migrate/schemaGeneratorAsync.d.ts +0 -9
- package/dist/migrate/schemaGeneratorAsync.d.ts.map +0 -1
- package/dist/migrate/schemaGeneratorAsync.js +0 -13
- package/dist/migrate/schemaGeneratorAsync.js.map +0 -1
- package/dist/migrate/storage/databaseStorage.d.ts +0 -25
- package/dist/migrate/storage/databaseStorage.d.ts.map +0 -1
- package/dist/migrate/storage/databaseStorage.js +0 -78
- package/dist/migrate/storage/databaseStorage.js.map +0 -1
- package/dist/migrate/storage/index.d.ts +0 -3
- package/dist/migrate/storage/index.d.ts.map +0 -1
- package/dist/migrate/storage/index.js +0 -3
- package/dist/migrate/storage/index.js.map +0 -1
- package/dist/migrate/storage/jsonStorage.d.ts +0 -16
- package/dist/migrate/storage/jsonStorage.d.ts.map +0 -1
- package/dist/migrate/storage/jsonStorage.js +0 -43
- package/dist/migrate/storage/jsonStorage.js.map +0 -1
- package/dist/migrate/sync/index.d.ts +0 -7
- package/dist/migrate/sync/index.d.ts.map +0 -1
- package/dist/migrate/sync/index.js +0 -7
- package/dist/migrate/sync/index.js.map +0 -1
- package/dist/migrate/sync/schemaSync.d.ts +0 -132
- package/dist/migrate/sync/schemaSync.d.ts.map +0 -1
- package/dist/migrate/sync/schemaSync.js +0 -260
- package/dist/migrate/sync/schemaSync.js.map +0 -1
- package/dist/mongo/index.d.ts +0 -6
- package/dist/mongo/index.d.ts.map +0 -1
- package/dist/mongo/index.js +0 -6
- package/dist/mongo/index.js.map +0 -1
- package/dist/mongo/mongoDialect.d.ts +0 -83
- package/dist/mongo/mongoDialect.d.ts.map +0 -1
- package/dist/mongo/mongoDialect.js +0 -418
- package/dist/mongo/mongoDialect.js.map +0 -1
- package/dist/mongo/mongodbNativeDialect.d.ts +0 -10
- package/dist/mongo/mongodbNativeDialect.d.ts.map +0 -1
- package/dist/mongo/mongodbNativeDialect.js +0 -10
- package/dist/mongo/mongodbNativeDialect.js.map +0 -1
- package/dist/mongo/mongodbQuerier.d.ts +0 -46
- package/dist/mongo/mongodbQuerier.d.ts.map +0 -1
- package/dist/mongo/mongodbQuerier.js +0 -344
- package/dist/mongo/mongodbQuerier.js.map +0 -1
- package/dist/mongo/mongodbQuerierPool.d.ts +0 -12
- package/dist/mongo/mongodbQuerierPool.d.ts.map +0 -1
- package/dist/mongo/mongodbQuerierPool.js +0 -19
- package/dist/mongo/mongodbQuerierPool.js.map +0 -1
- package/dist/mysql/index.d.ts +0 -5
- package/dist/mysql/index.d.ts.map +0 -1
- package/dist/mysql/index.js +0 -5
- package/dist/mysql/index.js.map +0 -1
- package/dist/mysql/mysql2Dialect.d.ts +0 -10
- package/dist/mysql/mysql2Dialect.d.ts.map +0 -1
- package/dist/mysql/mysql2Dialect.js +0 -10
- package/dist/mysql/mysql2Dialect.js.map +0 -1
- package/dist/mysql/mysql2Querier.d.ts +0 -12
- package/dist/mysql/mysql2Querier.d.ts.map +0 -1
- package/dist/mysql/mysql2Querier.js +0 -34
- package/dist/mysql/mysql2Querier.js.map +0 -1
- package/dist/mysql/mysql2QuerierPool.d.ts +0 -12
- package/dist/mysql/mysql2QuerierPool.d.ts.map +0 -1
- package/dist/mysql/mysql2QuerierPool.js +0 -18
- package/dist/mysql/mysql2QuerierPool.js.map +0 -1
- package/dist/mysql/mysqlDialect.d.ts +0 -6
- package/dist/mysql/mysqlDialect.d.ts.map +0 -1
- package/dist/mysql/mysqlDialect.js +0 -6
- package/dist/mysql/mysqlDialect.js.map +0 -1
- package/dist/namingStrategy/defaultNamingStrategy.d.ts +0 -10
- package/dist/namingStrategy/defaultNamingStrategy.d.ts.map +0 -1
- package/dist/namingStrategy/defaultNamingStrategy.js +0 -15
- package/dist/namingStrategy/defaultNamingStrategy.js.map +0 -1
- package/dist/namingStrategy/index.d.ts +0 -3
- package/dist/namingStrategy/index.d.ts.map +0 -1
- package/dist/namingStrategy/index.js +0 -3
- package/dist/namingStrategy/index.js.map +0 -1
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts +0 -9
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts.map +0 -1
- package/dist/namingStrategy/snakeCaseNamingStrategy.js +0 -14
- package/dist/namingStrategy/snakeCaseNamingStrategy.js.map +0 -1
- package/dist/neon/index.d.ts +0 -4
- package/dist/neon/index.d.ts.map +0 -1
- package/dist/neon/index.js +0 -4
- package/dist/neon/index.js.map +0 -1
- package/dist/neon/neonDialect.d.ts +0 -11
- package/dist/neon/neonDialect.d.ts.map +0 -1
- package/dist/neon/neonDialect.js +0 -11
- package/dist/neon/neonDialect.js.map +0 -1
- package/dist/neon/neonQuerier.d.ts +0 -6
- package/dist/neon/neonQuerier.d.ts.map +0 -1
- package/dist/neon/neonQuerier.js +0 -4
- package/dist/neon/neonQuerier.js.map +0 -1
- package/dist/neon/neonQuerierPool.d.ts +0 -11
- package/dist/neon/neonQuerierPool.d.ts.map +0 -1
- package/dist/neon/neonQuerierPool.js +0 -15
- package/dist/neon/neonQuerierPool.js.map +0 -1
- package/dist/options.d.ts +0 -5
- package/dist/options.d.ts.map +0 -1
- package/dist/options.js +0 -14
- package/dist/options.js.map +0 -1
- package/dist/postgres/abstractPgQuerier.d.ts +0 -24
- package/dist/postgres/abstractPgQuerier.d.ts.map +0 -1
- package/dist/postgres/abstractPgQuerier.js +0 -33
- package/dist/postgres/abstractPgQuerier.js.map +0 -1
- package/dist/postgres/abstractPgQuerierPool.d.ts +0 -15
- package/dist/postgres/abstractPgQuerierPool.d.ts.map +0 -1
- package/dist/postgres/abstractPgQuerierPool.js +0 -10
- package/dist/postgres/abstractPgQuerierPool.js.map +0 -1
- package/dist/postgres/index.d.ts +0 -6
- package/dist/postgres/index.d.ts.map +0 -1
- package/dist/postgres/index.js +0 -6
- package/dist/postgres/index.js.map +0 -1
- package/dist/postgres/pgDialect.d.ts +0 -13
- package/dist/postgres/pgDialect.d.ts.map +0 -1
- package/dist/postgres/pgDialect.js +0 -14
- package/dist/postgres/pgDialect.js.map +0 -1
- package/dist/postgres/pgQuerier.d.ts +0 -6
- package/dist/postgres/pgQuerier.d.ts.map +0 -1
- package/dist/postgres/pgQuerier.js +0 -4
- package/dist/postgres/pgQuerier.js.map +0 -1
- package/dist/postgres/pgQuerierPool.d.ts +0 -11
- package/dist/postgres/pgQuerierPool.d.ts.map +0 -1
- package/dist/postgres/pgQuerierPool.js +0 -15
- package/dist/postgres/pgQuerierPool.js.map +0 -1
- package/dist/postgres/postgresDialect.d.ts +0 -48
- package/dist/postgres/postgresDialect.d.ts.map +0 -1
- package/dist/postgres/postgresDialect.js +0 -222
- package/dist/postgres/postgresDialect.js.map +0 -1
- package/dist/postgres/postgresWireDriverCapabilities.d.ts +0 -15
- package/dist/postgres/postgresWireDriverCapabilities.d.ts.map +0 -1
- package/dist/postgres/postgresWireDriverCapabilities.js +0 -15
- package/dist/postgres/postgresWireDriverCapabilities.js.map +0 -1
- package/dist/querier/abstractPoolQuerier.d.ts +0 -14
- package/dist/querier/abstractPoolQuerier.d.ts.map +0 -1
- package/dist/querier/abstractPoolQuerier.js +0 -31
- package/dist/querier/abstractPoolQuerier.js.map +0 -1
- package/dist/querier/abstractQuerier.d.ts +0 -141
- package/dist/querier/abstractQuerier.d.ts.map +0 -1
- package/dist/querier/abstractQuerier.js +0 -431
- package/dist/querier/abstractQuerier.js.map +0 -1
- package/dist/querier/abstractQuerierPool.d.ts +0 -27
- package/dist/querier/abstractQuerierPool.d.ts.map +0 -1
- package/dist/querier/abstractQuerierPool.js +0 -31
- package/dist/querier/abstractQuerierPool.js.map +0 -1
- package/dist/querier/abstractSqlQuerier.d.ts +0 -53
- package/dist/querier/abstractSqlQuerier.d.ts.map +0 -1
- package/dist/querier/abstractSqlQuerier.js +0 -256
- package/dist/querier/abstractSqlQuerier.js.map +0 -1
- package/dist/querier/decorator/index.d.ts +0 -5
- package/dist/querier/decorator/index.d.ts.map +0 -1
- package/dist/querier/decorator/index.js +0 -5
- package/dist/querier/decorator/index.js.map +0 -1
- package/dist/querier/decorator/injectQuerier.d.ts +0 -4
- package/dist/querier/decorator/injectQuerier.d.ts.map +0 -1
- package/dist/querier/decorator/injectQuerier.js +0 -34
- package/dist/querier/decorator/injectQuerier.js.map +0 -1
- package/dist/querier/decorator/log.d.ts +0 -7
- package/dist/querier/decorator/log.d.ts.map +0 -1
- package/dist/querier/decorator/log.js +0 -27
- package/dist/querier/decorator/log.js.map +0 -1
- package/dist/querier/decorator/serialized.d.ts +0 -7
- package/dist/querier/decorator/serialized.d.ts.map +0 -1
- package/dist/querier/decorator/serialized.js +0 -14
- package/dist/querier/decorator/serialized.js.map +0 -1
- package/dist/querier/decorator/transactional.d.ts +0 -7
- package/dist/querier/decorator/transactional.d.ts.map +0 -1
- package/dist/querier/decorator/transactional.js +0 -49
- package/dist/querier/decorator/transactional.js.map +0 -1
- package/dist/querier/index.d.ts +0 -5
- package/dist/querier/index.d.ts.map +0 -1
- package/dist/querier/index.js +0 -5
- package/dist/querier/index.js.map +0 -1
- package/dist/schema/canonicalType.d.ts +0 -54
- package/dist/schema/canonicalType.d.ts.map +0 -1
- package/dist/schema/canonicalType.js +0 -571
- package/dist/schema/canonicalType.js.map +0 -1
- package/dist/schema/index.d.ts +0 -26
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -27
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/schemaAST.d.ts +0 -155
- package/dist/schema/schemaAST.d.ts.map +0 -1
- package/dist/schema/schemaAST.js +0 -496
- package/dist/schema/schemaAST.js.map +0 -1
- package/dist/schema/schemaASTBuilder.d.ts +0 -58
- package/dist/schema/schemaASTBuilder.d.ts.map +0 -1
- package/dist/schema/schemaASTBuilder.js +0 -228
- package/dist/schema/schemaASTBuilder.js.map +0 -1
- package/dist/schema/schemaASTDiffer.d.ts +0 -84
- package/dist/schema/schemaASTDiffer.d.ts.map +0 -1
- package/dist/schema/schemaASTDiffer.js +0 -431
- package/dist/schema/schemaASTDiffer.js.map +0 -1
- package/dist/schema/types.d.ts +0 -348
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/schema/types.js +0 -11
- package/dist/schema/types.js.map +0 -1
- package/dist/sqlite/abstractSqliteQuerier.d.ts +0 -4
- package/dist/sqlite/abstractSqliteQuerier.d.ts.map +0 -1
- package/dist/sqlite/abstractSqliteQuerier.js +0 -4
- package/dist/sqlite/abstractSqliteQuerier.js.map +0 -1
- package/dist/sqlite/betterSqlite3Dialect.d.ts +0 -10
- package/dist/sqlite/betterSqlite3Dialect.d.ts.map +0 -1
- package/dist/sqlite/betterSqlite3Dialect.js +0 -10
- package/dist/sqlite/betterSqlite3Dialect.js.map +0 -1
- package/dist/sqlite/index.d.ts +0 -6
- package/dist/sqlite/index.d.ts.map +0 -1
- package/dist/sqlite/index.js +0 -6
- package/dist/sqlite/index.js.map +0 -1
- package/dist/sqlite/sqliteDialect.d.ts +0 -36
- package/dist/sqlite/sqliteDialect.d.ts.map +0 -1
- package/dist/sqlite/sqliteDialect.js +0 -155
- package/dist/sqlite/sqliteDialect.js.map +0 -1
- package/dist/sqlite/sqliteQuerier.d.ts +0 -14
- package/dist/sqlite/sqliteQuerier.d.ts.map +0 -1
- package/dist/sqlite/sqliteQuerier.js +0 -30
- package/dist/sqlite/sqliteQuerier.js.map +0 -1
- package/dist/sqlite/sqliteQuerierPool.d.ts +0 -14
- package/dist/sqlite/sqliteQuerierPool.d.ts.map +0 -1
- package/dist/sqlite/sqliteQuerierPool.js +0 -36
- package/dist/sqlite/sqliteQuerierPool.js.map +0 -1
- package/dist/type/config.d.ts +0 -43
- package/dist/type/config.d.ts.map +0 -1
- package/dist/type/config.js +0 -2
- package/dist/type/config.js.map +0 -1
- package/dist/type/entity.d.ts +0 -332
- package/dist/type/entity.d.ts.map +0 -1
- package/dist/type/entity.js +0 -5
- package/dist/type/entity.js.map +0 -1
- package/dist/type/index.d.ts +0 -12
- package/dist/type/index.d.ts.map +0 -1
- package/dist/type/index.js +0 -12
- package/dist/type/index.js.map +0 -1
- package/dist/type/logger.d.ts +0 -61
- package/dist/type/logger.d.ts.map +0 -1
- package/dist/type/logger.js +0 -2
- package/dist/type/logger.js.map +0 -1
- package/dist/type/migration.d.ts +0 -267
- package/dist/type/migration.d.ts.map +0 -1
- package/dist/type/migration.js +0 -2
- package/dist/type/migration.js.map +0 -1
- package/dist/type/migratorDialect.d.ts +0 -10
- package/dist/type/migratorDialect.d.ts.map +0 -1
- package/dist/type/migratorDialect.js +0 -16
- package/dist/type/migratorDialect.js.map +0 -1
- package/dist/type/namingStrategy.d.ts +0 -18
- package/dist/type/namingStrategy.d.ts.map +0 -1
- package/dist/type/namingStrategy.js +0 -2
- package/dist/type/namingStrategy.js.map +0 -1
- package/dist/type/querier.d.ts +0 -167
- package/dist/type/querier.d.ts.map +0 -1
- package/dist/type/querier.js +0 -11
- package/dist/type/querier.js.map +0 -1
- package/dist/type/querierPool.d.ts +0 -62
- package/dist/type/querierPool.d.ts.map +0 -1
- package/dist/type/querierPool.js +0 -2
- package/dist/type/querierPool.js.map +0 -1
- package/dist/type/query.d.ts +0 -703
- package/dist/type/query.d.ts.map +0 -1
- package/dist/type/query.js +0 -11
- package/dist/type/query.js.map +0 -1
- package/dist/type/universalQuerier.d.ts +0 -136
- package/dist/type/universalQuerier.d.ts.map +0 -1
- package/dist/type/universalQuerier.js +0 -2
- package/dist/type/universalQuerier.js.map +0 -1
- package/dist/type/utility.d.ts +0 -37
- package/dist/type/utility.d.ts.map +0 -1
- package/dist/type/utility.js +0 -2
- package/dist/type/utility.js.map +0 -1
- package/dist/util/ansiSqlLiteral.d.ts +0 -21
- package/dist/util/ansiSqlLiteral.d.ts.map +0 -1
- package/dist/util/ansiSqlLiteral.js +0 -101
- package/dist/util/ansiSqlLiteral.js.map +0 -1
- package/dist/util/dialect.util.d.ts +0 -31
- package/dist/util/dialect.util.d.ts.map +0 -1
- package/dist/util/dialect.util.js +0 -113
- package/dist/util/dialect.util.js.map +0 -1
- package/dist/util/field.util.d.ts +0 -14
- package/dist/util/field.util.d.ts.map +0 -1
- package/dist/util/field.util.js +0 -57
- package/dist/util/field.util.js.map +0 -1
- package/dist/util/hook.util.d.ts +0 -15
- package/dist/util/hook.util.d.ts.map +0 -1
- package/dist/util/hook.util.js +0 -20
- package/dist/util/hook.util.js.map +0 -1
- package/dist/util/index.d.ts +0 -10
- package/dist/util/index.d.ts.map +0 -1
- package/dist/util/index.js +0 -10
- package/dist/util/index.js.map +0 -1
- package/dist/util/logger.d.ts +0 -34
- package/dist/util/logger.d.ts.map +0 -1
- package/dist/util/logger.js +0 -129
- package/dist/util/logger.js.map +0 -1
- package/dist/util/object.util.d.ts +0 -10
- package/dist/util/object.util.d.ts.map +0 -1
- package/dist/util/object.util.js +0 -29
- package/dist/util/object.util.js.map +0 -1
- package/dist/util/raw.d.ts +0 -18
- package/dist/util/raw.d.ts.map +0 -1
- package/dist/util/raw.js +0 -20
- package/dist/util/raw.js.map +0 -1
- package/dist/util/relationQuery.util.d.ts +0 -25
- package/dist/util/relationQuery.util.d.ts.map +0 -1
- package/dist/util/relationQuery.util.js +0 -101
- package/dist/util/relationQuery.util.js.map +0 -1
- package/dist/util/sql.util.d.ts +0 -50
- package/dist/util/sql.util.d.ts.map +0 -1
- package/dist/util/sql.util.js +0 -141
- package/dist/util/sql.util.js.map +0 -1
- package/dist/util/string.util.d.ts +0 -29
- package/dist/util/string.util.d.ts.map +0 -1
- package/dist/util/string.util.js +0 -93
- package/dist/util/string.util.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,749 +1,128 @@
|
|
|
1
1
|
<!--  -->
|
|
2
2
|
|
|
3
|
-
<
|
|
3
|
+
<picture>
|
|
4
|
+
<source srcset="assets/logo-dark.svg" media="(prefers-color-scheme: dark)">
|
|
5
|
+
<a href="https://uql-orm.dev"><img src="assets/logo.svg" alt="uql" width="80" /></a>
|
|
6
|
+
</picture>
|
|
4
7
|
|
|
5
|
-
[](https://github.com/rogerpadilla/uql) [](https://coveralls.io/github/rogerpadilla/uql?branch=main) [](https://github.com/rogerpadilla/uql/blob/main/LICENSE) [](https://www.npmjs.com/package/uql-orm)
|
|
8
|
+
[](https://github.com/rogerpadilla/uql/actions/workflows/tests.yml) [](https://coveralls.io/github/rogerpadilla/uql?branch=main) [](https://github.com/rogerpadilla/uql/blob/main/LICENSE) [](https://www.npmjs.com/package/uql-orm)
|
|
6
9
|
|
|
7
|
-
**[UQL](https://uql-orm.dev)** is the
|
|
10
|
+
**[UQL](https://uql-orm.dev)** is the JSON-native TypeScript ORM: serializable queries, no codegen, and one API across PostgreSQL, MySQL, SQLite, MariaDB, and MongoDB. Define entities once, query everywhere.
|
|
11
|
+
|
|
12
|
+
<!-- DEMO: Record an animated GIF showing IDE autocompletion for $select/$populate/$where and embed here. Example:  -->
|
|
8
13
|
|
|
9
14
|
```ts
|
|
10
|
-
|
|
11
|
-
$select: { name: true },
|
|
12
|
-
$
|
|
13
|
-
$where: { name: { $istartsWith: 'a' }, posts: { tags: { name: 'typescript' } } },
|
|
14
|
-
$sort: { createdAt: 'desc' },
|
|
15
|
+
await querier.findMany(User, {
|
|
16
|
+
$select: { id: true, name: true },
|
|
17
|
+
$where: { email: { $endsWith: '@uql-orm.dev' } },
|
|
15
18
|
$limit: 10,
|
|
16
19
|
});
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
npm install uql-orm pg
|
|
23
|
-
```
|
|
24
|
-
_(Example using PostgreSQL; see [Install](#1-install) for other databases)_
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
import { PgQuerierPool } from 'uql-orm/postgres';
|
|
28
|
-
|
|
29
|
-
const pool = new PgQuerierPool({ host: 'localhost', database: 'app' });
|
|
30
|
-
const users = await pool.withQuerier((querier) => querier.findMany(User, { $limit: 10 }));
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
For production setup and migrations, jump to:
|
|
34
|
-
- [Install](#1-install)
|
|
35
|
-
- [Define your Entities](#2-define-your-entities)
|
|
36
|
-
- [Migrations & Synchronization](#5-migrations--synchronization)
|
|
22
|
+
Full docs: **[uql-orm.dev](https://uql-orm.dev)**
|
|
37
23
|
|
|
38
|
-
|
|
24
|
+
---
|
|
39
25
|
|
|
40
|
-
##
|
|
26
|
+
## Why UQL?
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
- [
|
|
46
|
-
- [4. Manipulate the Data](#4-manipulate-the-data)
|
|
47
|
-
- [5. Migrations & Synchronization](#5-migrations--synchronization)
|
|
48
|
-
|
|
49
|
-
Advanced and operations:
|
|
50
|
-
- [Semantic Search](#modern-indexing-semantic-search)
|
|
51
|
-
- [JSON Operators & Relation Filtering](#json-operators--relation-filtering)
|
|
52
|
-
- [Thread-Safe Transactions](#thread-safe-transactions)
|
|
53
|
-
- [6. Logging & Monitoring](#6-logging--monitoring)
|
|
54
|
-
- [Deep Dive: Tests & Technical Resources](#deep-dive-tests--technical-resources)
|
|
28
|
+
- **Queries are data, not method chains.** A UQL query is a plain JSON object. Build them dynamically, store them, or send them from client to server without a DSL.
|
|
29
|
+
- **No codegen, no build step.** Entities are TypeScript classes, so your code *is* the schema. No `.prisma` files or generated clients to keep in sync.
|
|
30
|
+
- **One API everywhere.** The same syntax runs on PostgreSQL, MySQL, MariaDB, SQLite, LibSQL, Neon, Cloudflare D1, MongoDB, and Bun's native SQL.
|
|
31
|
+
- **Fast by design.** Fastest in [all 8 categories](https://uql-orm.dev/benchmark) of our [open benchmark](https://github.com/rogerpadilla/ts-orm-benchmark): on average ~2.1× faster than the runner-up, reaching 3.5M ops/s on SELECTs and DELETEs.
|
|
55
32
|
|
|
56
33
|
## Features
|
|
57
34
|
|
|
58
|
-
| Feature |
|
|
35
|
+
| Feature | Docs |
|
|
59
36
|
| :--- | :--- |
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
| **[Aggregate Queries](https://uql-orm.dev/querying/aggregate)** | Real-time analytics with `GROUP BY`, `HAVING`, and native math operators across all dialects. |
|
|
69
|
-
| **[Semantic Search](https://uql-orm.dev/querying/semantic-search)** | Native vector similarity search. Rank results by meaning using standard ORM operators. |
|
|
70
|
-
| **[Cursor Streaming](https://uql-orm.dev/querying/streaming)** | Process millions of rows with a stable memory footprint using native driver-level cursors. |
|
|
71
|
-
| **[Modern & Versatile](https://uql-orm.dev/entities/virtual-fields)** | Pure ESM, high-res timing, built-in soft-delete, and first-class JSON/JSONB support. |
|
|
72
|
-
| **[Database Migrations](https://www.uql-orm.dev/migrations)** | Entity-First synchronization. DDL is auto-generated by diffing your code against the live DB. |
|
|
73
|
-
| **[Logging & Monitoring](https://www.uql-orm.dev/logging)** | High-visibility debugging with slow-query detection and high-contrast terminal output. |
|
|
74
|
-
| **[Fullstack Bridge](https://www.uql-orm.dev/comparison#network-boundaries--apis)** | Speak to your database from the browser securely. First-party `HttpQuerier` removes API boilerplate. |
|
|
75
|
-
|
|
76
|
-
## 1. Install
|
|
77
|
-
|
|
78
|
-
Install the core package and the driver for your database:
|
|
37
|
+
| Unified API across SQL + MongoDB | [Install](https://uql-orm.dev/getting-started) |
|
|
38
|
+
| Type-safe queries with autocomplete | [Querying](https://uql-orm.dev/querying/querier) |
|
|
39
|
+
| Entity-first migrations & autoSync | [Migrations](https://uql-orm.dev/migrations) |
|
|
40
|
+
| Soft-delete, lifecycle hooks, relations | [Entities](https://uql-orm.dev/entities/basic) |
|
|
41
|
+
| Aggregate queries, grouping, HAVING | [Aggregate](https://uql-orm.dev/querying/aggregate) |
|
|
42
|
+
| Semantic search & vector similarity | [Semantic Search](https://uql-orm.dev/ai-semantic-search) |
|
|
43
|
+
| Streaming, transactions, raw SQL | [Querying](https://uql-orm.dev/querying/querier) |
|
|
44
|
+
| NestJS integration & HttpQuerier | [Fullstack](https://uql-orm.dev/comparison) |
|
|
79
45
|
|
|
80
|
-
|
|
81
|
-
# Core
|
|
82
|
-
npm install uql-orm # or bun add / pnpm add
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Supported Drivers (pick according to your database)
|
|
46
|
+
## Install
|
|
86
47
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
| **PostgreSQL** (incl. Neon, Cockroach, Yugabyte) | `npm install pg` |
|
|
90
|
-
| **MySQL** (incl. TiDB, Aurora) | `npm install mysql2` |
|
|
91
|
-
| **MariaDB** | `npm install mariadb` |
|
|
92
|
-
| **SQLite** | `npm install better-sqlite3` |
|
|
93
|
-
| **LibSQL** (incl. Turso) | `npm install @libsql/client` |
|
|
94
|
-
| **MongoDB** | `npm install mongodb` |
|
|
95
|
-
| **Cloudflare D1** | _Native (no driver needed)_ |
|
|
96
|
-
| **Bun SQL Native** (Incl. Postgres, MySQL, SQLite) | _Native (via `bun:sql`)_ |
|
|
97
|
-
|
|
98
|
-
### TypeScript Configuration
|
|
99
|
-
|
|
100
|
-
If you use the **decorator-based approach**, make sure your `tsconfig.json` is configured to support decorators and metadata:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```json
|
|
104
|
-
{
|
|
105
|
-
"compilerOptions": {
|
|
106
|
-
"experimentalDecorators": true,
|
|
107
|
-
"emitDecoratorMetadata": true
|
|
108
|
-
}
|
|
109
|
-
}
|
|
48
|
+
```sh
|
|
49
|
+
npm install uql-orm pg # or mysql2, mariadb, better-sqlite3, mongodb, @libsql/client
|
|
110
50
|
```
|
|
111
51
|
|
|
112
|
-
|
|
52
|
+
Supports PostgreSQL, MySQL, MariaDB, SQLite, CockroachDB, LibSQL/Turso, Neon, MongoDB, Cloudflare D1, and Bun SQL.
|
|
113
53
|
|
|
114
|
-
##
|
|
54
|
+
## Define Entities
|
|
115
55
|
|
|
116
|
-
[Declare](https://uql-orm.dev/entities/basic) your classes with decorators
|
|
117
|
-
|
|
118
|
-
### Core Decorators
|
|
119
|
-
|
|
120
|
-
| Decorator | Purpose |
|
|
121
|
-
| :--- | :--- |
|
|
122
|
-
| `@Entity()` | Marks a class as a database table/collection. |
|
|
123
|
-
| `@Id()` | Defines the Primary Key with support for `onInsert` generators. |
|
|
124
|
-
| `@Field()` | Standard column. Use `{ references: ... }` for Foreign Keys. |
|
|
125
|
-
| `@Index()` | Defines a composite or custom index on one or more columns. |
|
|
126
|
-
| `@OneToOne` | Defines a one-to-one relationship. |
|
|
127
|
-
| `@OneToMany` | Defines a one-to-many relationship. |
|
|
128
|
-
| `@ManyToOne` | Defines a many-to-one relationship. |
|
|
129
|
-
| `@ManyToMany` | Defines a many-to-many relationship. |
|
|
130
|
-
| `@BeforeInsert` | Lifecycle hooks fired around database operations. |
|
|
131
|
-
| `@AfterLoad` | Lifecycle hook fired after loading entities. |
|
|
132
|
-
|
|
133
|
-
### Type Abstraction: Logical vs. Physical
|
|
134
|
-
|
|
135
|
-
UQL separates the **intent** of your data from its **storage**. Both properties are **optional**; if omitted, UQL performs a *best-effort inference* using the TypeScript types from your class.
|
|
136
|
-
|
|
137
|
-
| Property | Purpose | Values |
|
|
138
|
-
| :--- | :--- | :--- |
|
|
139
|
-
| **`type`** | **Logical Type** (Abstraction). Used for runtime behavior and automatic SQL mapping. | `String`, `Number`, `Boolean`, `Date`, `BigInt`, or semantic strings: `'uuid'`, `'json'`, `'vector'`, `'halfvec'`, `'sparsevec'`. |
|
|
140
|
-
| **`columnType`** | **Physical Type** (Implementation). **Highest Priority**. Bypasses UQL's inference for exact SQL control. | Raw SQL types: `'varchar(100)'`, `'decimal(10,2)'`, `'smallint'`, etc. |
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
// Automatic inference from TypeScript types
|
|
144
|
-
@Field() name?: string; // → TEXT (Postgres), VARCHAR(255) (MySQL)
|
|
145
|
-
@Field() age?: number; // → INTEGER
|
|
146
|
-
@Field() isActive?: boolean; // → BOOLEAN
|
|
147
|
-
@Field() createdAt?: Date; // → TIMESTAMP
|
|
148
|
-
|
|
149
|
-
// Semantic types - portable across all databases
|
|
150
|
-
@Field({ type: 'uuid' }) // → UUID (Postgres), CHAR(36) (MySQL), TEXT (SQLite)
|
|
151
|
-
externalId?: string;
|
|
152
|
-
|
|
153
|
-
@Field({ type: 'json' }) // → JSONB (Postgres), JSON (MySQL), TEXT (SQLite)
|
|
154
|
-
metadata?: Json<{ theme?: string }>;
|
|
155
|
-
|
|
156
|
-
// Logical types with constraints - portable with control
|
|
157
|
-
@Field({ type: 'varchar', length: 500 })
|
|
158
|
-
bio?: string;
|
|
159
|
-
|
|
160
|
-
@Field({ type: 'decimal', precision: 10, scale: 2 })
|
|
161
|
-
price?: number;
|
|
162
|
-
|
|
163
|
-
// Exact SQL type - when you need dialect-specific control
|
|
164
|
-
@Field({ columnType: 'smallint' })
|
|
165
|
-
statusCode?: number;
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
> **Note:** Use the `Relation<T>` utility type for relationship properties. It prevents TypeScript circular dependency errors while maintaining full type-safety throughout your app.
|
|
56
|
+
[Declare](https://uql-orm.dev/entities/basic) your classes with decorators. UQL uses this metadata for type-safe querying and DDL generation.
|
|
169
57
|
|
|
170
58
|
```ts
|
|
171
59
|
import { v7 as uuidv7 } from 'uuid';
|
|
172
|
-
import { Entity, Id, Field, OneToOne, OneToMany,
|
|
60
|
+
import { Entity, Id, Field, OneToOne, OneToMany, type Relation } from 'uql-orm';
|
|
173
61
|
|
|
174
62
|
@Entity()
|
|
175
63
|
export class User {
|
|
176
64
|
@Id({ type: 'uuid', onInsert: () => uuidv7() })
|
|
177
65
|
id?: string;
|
|
178
66
|
|
|
179
|
-
@Field({
|
|
180
|
-
index: true,
|
|
181
|
-
})
|
|
182
|
-
name?: string;
|
|
183
|
-
|
|
184
|
-
@Field({
|
|
185
|
-
unique: true,
|
|
186
|
-
comment: 'User login email',
|
|
187
|
-
})
|
|
67
|
+
@Field({ index: true, unique: true })
|
|
188
68
|
email?: string;
|
|
189
69
|
|
|
190
|
-
@OneToOne({
|
|
191
|
-
entity: () => Profile,
|
|
192
|
-
mappedBy: (profile) => profile.user,
|
|
193
|
-
cascade: true,
|
|
194
|
-
})
|
|
70
|
+
@OneToOne({ entity: () => Profile, mappedBy: (p) => p.user, cascade: true })
|
|
195
71
|
profile?: Relation<Profile>;
|
|
196
72
|
|
|
197
|
-
@OneToMany({
|
|
198
|
-
entity: () => Post,
|
|
199
|
-
mappedBy: (post) => post.author,
|
|
200
|
-
})
|
|
73
|
+
@OneToMany({ entity: () => Post, mappedBy: (p) => p.author })
|
|
201
74
|
posts?: Relation<Post>[];
|
|
202
75
|
}
|
|
203
|
-
|
|
204
|
-
@Entity()
|
|
205
|
-
export class Profile {
|
|
206
|
-
@Id({ type: 'uuid', onInsert: () => uuidv7() })
|
|
207
|
-
id?: string;
|
|
208
|
-
|
|
209
|
-
@Field()
|
|
210
|
-
bio?: string;
|
|
211
|
-
|
|
212
|
-
@Field({ references: () => User, foreignKey: 'fk_profile_user' })
|
|
213
|
-
userId?: string;
|
|
214
|
-
|
|
215
|
-
@OneToOne({ entity: () => User })
|
|
216
|
-
user?: User;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
@Entity()
|
|
220
|
-
export class Post {
|
|
221
|
-
@Id()
|
|
222
|
-
id?: number;
|
|
223
|
-
|
|
224
|
-
@Field()
|
|
225
|
-
title?: string;
|
|
226
|
-
|
|
227
|
-
@Field({ references: () => User })
|
|
228
|
-
authorId?: string;
|
|
229
|
-
|
|
230
|
-
@ManyToOne({ entity: () => User })
|
|
231
|
-
author?: User;
|
|
232
|
-
|
|
233
|
-
@ManyToMany({
|
|
234
|
-
entity: () => Tag,
|
|
235
|
-
through: () => PostTag,
|
|
236
|
-
})
|
|
237
|
-
tags?: Tag[];
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@Entity()
|
|
241
|
-
export class Tag {
|
|
242
|
-
@Id({ type: 'uuid', onInsert: () => uuidv7() })
|
|
243
|
-
id?: string;
|
|
244
|
-
|
|
245
|
-
@Field()
|
|
246
|
-
name?: string;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
@Entity()
|
|
250
|
-
export class PostTag {
|
|
251
|
-
@Id({ type: 'uuid', onInsert: () => uuidv7() })
|
|
252
|
-
id?: string;
|
|
253
|
-
|
|
254
|
-
@Field({ references: () => Post })
|
|
255
|
-
postId?: number;
|
|
256
|
-
|
|
257
|
-
@Field({ references: () => Tag })
|
|
258
|
-
tagId?: string;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
### Alternative: Imperative (Decorator-free) Definition
|
|
262
|
-
|
|
263
|
-
If you prefer a functional approach or are in an environment where decorators are disabled (e.g., some edge runtimes or specific build pipelines), you can register entities imperatively using `defineEntity`. **Crucially, this approach works without requiring `experimentalDecorators` or `emitDecoratorMetadata` in your `tsconfig.json`.**
|
|
264
|
-
|
|
265
|
-
This API supports bulk configuration of `fields`, `relations`, `indexes`, and `hooks` directly within the options object. UQL also exports helper functions like `defineField`, `defineId`, and `defineRelation` to assist with type-safe imperative setup.
|
|
266
|
-
|
|
267
|
-
```ts
|
|
268
|
-
import { defineEntity } from 'uql-orm';
|
|
269
|
-
|
|
270
|
-
class User {}
|
|
271
|
-
|
|
272
|
-
defineEntity(User, {
|
|
273
|
-
name: 'users',
|
|
274
|
-
fields: {
|
|
275
|
-
id: { type: 'uuid', isId: true },
|
|
276
|
-
name: { type: String },
|
|
277
|
-
email: { type: String, unique: true },
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
indexes: [
|
|
281
|
-
{ columns: ['email'], unique: true },
|
|
282
|
-
],
|
|
283
|
-
// You can also define hooks and relations here
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
## 3. Set up a pool
|
|
290
|
-
|
|
291
|
-
A pool manages connections (queriers). Initialize it once at application bootstrap (e.g., in `server.ts`).
|
|
292
|
-
|
|
293
|
-
```ts
|
|
294
|
-
import { SnakeCaseNamingStrategy, type Config } from 'uql-orm';
|
|
295
|
-
import { PgQuerierPool } from 'uql-orm/postgres'; // or mysql2, sqlite, bunSql, etc.
|
|
296
|
-
import { User, Profile, Post } from './entities';
|
|
297
|
-
|
|
298
|
-
export const pool = new PgQuerierPool(
|
|
299
|
-
{ host: 'localhost', database: 'uql_app', max: 10 },
|
|
300
|
-
{
|
|
301
|
-
logger: ['error', 'warn', 'migration'],
|
|
302
|
-
namingStrategy: new SnakeCaseNamingStrategy(),
|
|
303
|
-
slowQuery: { threshold: 1000 },
|
|
304
|
-
}
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
export default {
|
|
308
|
-
pool,
|
|
309
|
-
entities: [User, Profile, Post],
|
|
310
|
-
migrationsPath: './migrations',
|
|
311
|
-
} satisfies Config;
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
> **Notes:**
|
|
315
|
-
> - Reuse one pool for both app queries and migrations to keep behavior (for example naming strategy) consistent.
|
|
316
|
-
> - **LibSQL embedded replica** (`file:` + `syncUrl`): `LibsqlQuerierPool` runs **migrations and the `uql_migrations` table** against **`syncUrl`**, while **`getQuerier`** stays on the local file. **`getDiffs` / introspection** (e.g. `generate:entities`) still use the normal pool connection—often the local replica—so compare with your remote if needed.
|
|
317
|
-
> - If your architecture spans backend + browser, `HttpQuerier` reduces custom API mapping and keeps query semantics aligned.
|
|
318
|
-
> - **Upgrading:** use `pool.dialect` (not `pool.dialectInstance`), read `pool.dialect.dialectName`, and remove any top-level `dialect` from migrate config (see `CHANGELOG.md`).
|
|
319
|
-
|
|
320
|
-
### Driver → pool → dialect class
|
|
321
|
-
|
|
322
|
-
Migrations and the CLI read **`pool.dialect.dialectName`** only (there is no separate top-level `dialect` in config). Pick the pool (and thus the dialect class) for your driver.
|
|
323
|
-
|
|
324
|
-
| Import path | Pool class | Dialect class (on the pool) | Notes |
|
|
325
|
-
| :--- | :--- | :--- | :--- |
|
|
326
|
-
| `uql-orm/postgres` | `PgQuerierPool` | `PgDialect` | Node `pg`; base Postgres capabilities (native arrays, `$n::jsonb`). |
|
|
327
|
-
| `uql-orm/postgres` | — | `PostgresDialect` | Base Postgres AST; subclass for other Postgres wire drivers. |
|
|
328
|
-
| `uql-orm/neon` | `NeonQuerierPool` | `NeonDialect` | `@neondatabase/serverless`; extends `PostgresDialect` with Neon-oriented defaults. |
|
|
329
|
-
| `uql-orm/cockroachdb` | `CrdbQuerierPool` | `CockroachDialect` | `dialectName` is `cockroachdb`; extends `PostgresDialect`. |
|
|
330
|
-
| `uql-orm/mysql` | `Mysql2QuerierPool` | `MySql2Dialect` | `mysql2` driver. |
|
|
331
|
-
| `uql-orm/maria` | `MariadbQuerierPool` | `MariaDialect` | `mariadb` driver. |
|
|
332
|
-
| `uql-orm/sqlite` | `Sqlite3QuerierPool` | `BetterSqlite3Dialect` | `better-sqlite3` (or Bun SQLite in that pool). |
|
|
333
|
-
| `uql-orm/libsql` | `LibsqlQuerierPool` | `LibsqlDialect` | `@libsql/client`. |
|
|
334
|
-
| `uql-orm/d1` | `D1QuerierPool` | `D1SqliteDialect` | Cloudflare D1. |
|
|
335
|
-
| `uql-orm/mongo` | `MongodbQuerierPool` | `MongodbNativeDialect` | Official `mongodb` driver. |
|
|
336
|
-
| `uql-orm/bunSql` | `BunSqlQuerierPool` | _inferred_ | Dialect class chosen from `SQL.Options` (Postgres / MySQL / MariaDB / SQLite / Cockroach). |
|
|
337
|
-
|
|
338
|
-
For **wire-level** differences on PostgreSQL (e.g. Bun SQL vs `pg`), `BunSqlPostgresDialect` merges `POSTGRES_WIRE_DRIVER_CAPABILITIES` from `uql-orm/postgres/wireCapabilities` (array literals + JSON text cast); `PgDialect` does not.
|
|
339
|
-
|
|
340
|
-
## 4. Manipulate the Data
|
|
341
|
-
|
|
342
|
-
UQL provides a straightforward API to interact with your data. **Always ensure queriers are released back to the pool.**
|
|
343
|
-
|
|
344
|
-
### Core Query Pattern
|
|
345
|
-
|
|
346
|
-
```ts
|
|
347
|
-
const querier = await pool.getQuerier();
|
|
348
|
-
try {
|
|
349
|
-
const results = await querier.findMany(User, {
|
|
350
|
-
$select: { name: true },
|
|
351
|
-
$populate: { profile: { $select: { bio: true }, $required: true } }, // INNER JOIN
|
|
352
|
-
$where: {
|
|
353
|
-
status: 'active',
|
|
354
|
-
name: { $istartsWith: 'a' },
|
|
355
|
-
},
|
|
356
|
-
$limit: 10,
|
|
357
|
-
});
|
|
358
|
-
} finally {
|
|
359
|
-
await querier.release(); // Always release back to the pool
|
|
360
|
-
}
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
**Generated SQL (PostgreSQL):**
|
|
364
|
-
|
|
365
|
-
```sql
|
|
366
|
-
SELECT "User"."name", "profile"."id" AS "profile_id", "profile"."bio" AS "profile_bio"
|
|
367
|
-
FROM "User"
|
|
368
|
-
INNER JOIN "Profile" AS "profile" ON "profile"."userId" = "User"."id"
|
|
369
|
-
WHERE "User"."status" = 'active' AND "User"."name" ILIKE 'a%'
|
|
370
|
-
LIMIT 10 OFFSET 0
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
### Projection & Relation Loading
|
|
374
|
-
|
|
375
|
-
Use these query keys with clear separation of concerns:
|
|
376
|
-
|
|
377
|
-
- `$select`: scalar field whitelist (projection)
|
|
378
|
-
- `$exclude`: scalar field subtraction from default eager set
|
|
379
|
-
- `$populate`: relation loading (including nested relation query options)
|
|
380
|
-
|
|
381
|
-
`$select` and `$exclude` are mutually exclusive when `$select` includes positive scalar keys.
|
|
382
|
-
|
|
383
|
-
```ts
|
|
384
|
-
const rows = await querier.findMany(User, {
|
|
385
|
-
$exclude: { password: true },
|
|
386
|
-
$populate: { profile: { $select: { picture: true } } },
|
|
387
|
-
});
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
> **Migration note:** selecting relations inside `$select` is still supported for backward compatibility, but deprecated. Move relations to `$populate`.
|
|
391
|
-
|
|
392
|
-
### Streaming (`findManyStream`) and relations
|
|
393
|
-
|
|
394
|
-
`findManyStream` is optimized for **scalar** reads and a stable memory footprint. Relation loading differs by backend:
|
|
395
|
-
|
|
396
|
-
- **SQL:** Joinable relations (e.g. many-to-one, one-to-one) are still included in the streamed `SELECT` / joins. **To-many** collections are not filled on the stream path (that uses extra queries in `findMany`); requesting them in `$select` / `$populate` throws a `TypeError` with a short explanation.
|
|
397
|
-
- **MongoDB:** Streams use a plain `find` cursor, so **any** relation keys in `$select` or `$populate` throw a `TypeError`. Use `findMany` for relation loading (aggregation + fill).
|
|
398
|
-
|
|
399
|
-
See [Cursor Streaming](https://uql-orm.dev/querying/streaming) on the docs site for details.
|
|
400
|
-
|
|
401
|
-
### Advanced Query Patterns
|
|
402
|
-
|
|
403
|
-
### Modern Indexing: Semantic Search
|
|
404
|
-
|
|
405
|
-
AI-driven applications require ranking results by meaning. UQL treats vector similarity as a first-class citizen, allowing you to perform semantic search without raw SQL or proprietary extensions.
|
|
406
|
-
|
|
407
|
-
```ts
|
|
408
|
-
const results = await querier.findMany(Item, {
|
|
409
|
-
$select: { id: true, title: true },
|
|
410
|
-
$sort: { $vector: { embedding: queryVector } },
|
|
411
|
-
$limit: 10,
|
|
412
|
-
});
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### Advanced: Virtual Fields & Raw SQL
|
|
416
|
-
|
|
417
|
-
Define complex logic directly in your entities using `raw` functions. These are resolved during SQL generation for peak efficiency.
|
|
418
|
-
|
|
419
|
-
```ts
|
|
420
|
-
@Entity()
|
|
421
|
-
export class Item {
|
|
422
|
-
@Field({
|
|
423
|
-
virtual: raw(({ ctx, dialect, escapedPrefix }) => {
|
|
424
|
-
ctx.append('(');
|
|
425
|
-
dialect.count(ctx, ItemTag, {
|
|
426
|
-
$where: { itemId: raw(({ ctx }) => ctx.append(`${escapedPrefix}.id`)) }
|
|
427
|
-
}, { autoPrefix: true });
|
|
428
|
-
ctx.append(')');
|
|
429
|
-
})
|
|
430
|
-
})
|
|
431
|
-
tagsCount?: number;
|
|
432
|
-
}
|
|
433
76
|
```
|
|
434
77
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
Query nested JSON fields using **type-safe dot-notation** with full operator support. Wrap fields with `Json<T>` to get IDE autocompletion for valid paths. UQL generates native SQL per dialect.
|
|
438
|
-
|
|
439
|
-
```ts
|
|
440
|
-
// Filter by nested JSONB field paths
|
|
441
|
-
const items = await querier.findMany(Company, {
|
|
442
|
-
$where: {
|
|
443
|
-
'settings.isArchived': { $ne: true },
|
|
444
|
-
'settings.priority': { $gte: 5 },
|
|
445
|
-
},
|
|
446
|
-
});
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
**PostgreSQL:** `WHERE ("settings"->>'isArchived') IS DISTINCT FROM $1 AND (("settings"->>'priority'))::numeric >= $2`
|
|
450
|
-
**MySQL:** `WHERE (\`settings\`->>'isArchived') <> ? AND CAST((\`settings\`->>'priority') AS DECIMAL) >= ?`
|
|
451
|
-
**MariaDB:** `WHERE JSON_VALUE(\`settings\`, '$.isArchived') <> ? AND CAST(JSON_VALUE(\`settings\`, '$.priority') AS DECIMAL) >= ?`
|
|
452
|
-
**SQLite:** `WHERE json_extract("settings", '$.isArchived') IS NOT ? AND CAST(json_extract("settings", '$.priority') AS REAL) >= ?`
|
|
453
|
-
|
|
454
|
-
Atomic JSON updates support `$merge`, `$unset`, and `$push`:
|
|
455
|
-
|
|
456
|
-
```ts
|
|
457
|
-
await querier.updateOneById(Company, id, {
|
|
458
|
-
settings: { $merge: { theme: 'dark' }, $push: { tags: 'orm' }, $unset: ['deprecated'] },
|
|
459
|
-
});
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
> **Modern DB Baselines used by docs/examples:** PostgreSQL 16+, MySQL 8.4+ (LTS), MariaDB 12.2+, SQLite 3.45+.
|
|
463
|
-
> Full generated SQL examples: [JSON / JSONB docs](https://uql-orm.dev/querying/json).
|
|
464
|
-
|
|
465
|
-
Filter parent entities by their **ManyToMany** or **OneToMany** relations using automatic EXISTS subqueries:
|
|
466
|
-
|
|
467
|
-
```ts
|
|
468
|
-
// Find posts that have a tag named 'typescript'
|
|
469
|
-
const posts = await querier.findMany(Post, {
|
|
470
|
-
$where: { tags: { name: 'typescript' } },
|
|
471
|
-
});
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
**PostgreSQL:** `WHERE EXISTS (SELECT 1 FROM "PostTag" WHERE "PostTag"."postId" = "Post"."id" AND "PostTag"."tagId" IN (SELECT "Tag"."id" FROM "Tag" WHERE "Tag"."name" = $1))`
|
|
475
|
-
|
|
476
|
-
> **Note:** Wrap JSON fields with `Json<T>` to get autocompletion for valid dot-notation paths.
|
|
477
|
-
|
|
478
|
-
### Aggregate Queries
|
|
78
|
+
> **Imperative API:** `defineEntity(User, { fields: { id: { type: 'uuid', isId: true } }, ... })`. No decorators needed. See [Imperative Definition](https://uql-orm.dev/entities/imperative).
|
|
479
79
|
|
|
480
|
-
|
|
80
|
+
## Querying
|
|
481
81
|
|
|
482
82
|
```ts
|
|
483
|
-
|
|
484
|
-
$
|
|
485
|
-
|
|
486
|
-
total: { $sum: 'amount' },
|
|
487
|
-
count: { $count: '*' },
|
|
488
|
-
},
|
|
489
|
-
$having: { count: { $gt: 5 } },
|
|
490
|
-
$sort: { total: -1 },
|
|
83
|
+
await querier.findMany(User, {
|
|
84
|
+
$select: { id: true, name: true },
|
|
85
|
+
$where: { email: { $endsWith: '@uql-orm.dev' } },
|
|
491
86
|
$limit: 10,
|
|
492
87
|
});
|
|
493
88
|
```
|
|
494
89
|
|
|
495
|
-
|
|
90
|
+
25+ comparison operators (`$eq`, `$in`, `$between`, `$like`, `$elemMatch`), logical operators (`$and`, `$or`, `$not`, `$nor`), and type-safe JSON/JSONB dot-notation queries.
|
|
496
91
|
|
|
497
|
-
|
|
498
|
-
SELECT "status", SUM("amount") "total", COUNT(*) "count"
|
|
499
|
-
FROM "Order"
|
|
500
|
-
GROUP BY "status"
|
|
501
|
-
HAVING COUNT(*) > $1
|
|
502
|
-
ORDER BY SUM("amount") DESC
|
|
503
|
-
LIMIT 10
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
For `SELECT DISTINCT`, add `$distinct: true` to any find query:
|
|
507
|
-
|
|
508
|
-
```ts
|
|
509
|
-
const names = await querier.findMany(User, {
|
|
510
|
-
$select: { name: true },
|
|
511
|
-
$distinct: true,
|
|
512
|
-
});
|
|
513
|
-
// → SELECT DISTINCT "name" FROM "User"
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
> **Learn more**: See the full [Aggregate Queries guide](https://uql-orm.dev/querying/aggregate) for `$having` operators, MongoDB pipeline details, and advanced patterns.
|
|
517
|
-
|
|
518
|
-
### Cursor-Based Streaming
|
|
519
|
-
|
|
520
|
-
For large result sets, use `findManyStream()` to iterate row-by-row without loading everything into memory. Each driver uses its optimal native cursor API.
|
|
521
|
-
|
|
522
|
-
```ts
|
|
523
|
-
for await (const user of querier.findManyStream(User, { $where: { active: true } })) {
|
|
524
|
-
process.stdout.write(JSON.stringify(user) + '\n');
|
|
525
|
-
}
|
|
526
|
-
```
|
|
92
|
+
> [Querying](https://uql-orm.dev/querying/querier) · [Operators](https://uql-orm.dev/querying/comparison-operators) · [JSON](https://uql-orm.dev/querying/json)
|
|
527
93
|
|
|
528
|
-
|
|
94
|
+
## Transactions
|
|
529
95
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
#### Option A: Manual (Functional)
|
|
96
|
+
Functional `pool.transaction()` or `@Transactional()` decorator with centralized serialization:
|
|
533
97
|
|
|
534
98
|
```ts
|
|
535
|
-
const
|
|
536
|
-
const
|
|
537
|
-
await
|
|
99
|
+
const userId = await pool.transaction(async (q) => {
|
|
100
|
+
const id = await q.insertOne(User, { email: 'a@b.com' });
|
|
101
|
+
await q.insertOne(Profile, { userId: id, bio: '...' });
|
|
102
|
+
return id;
|
|
538
103
|
});
|
|
539
104
|
```
|
|
540
105
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
Perfect for **NestJS** and other Dependency Injection frameworks. Use `@Transactional()` to wrap a method and `@InjectQuerier()` to access the managed connection.
|
|
544
|
-
|
|
545
|
-
```ts
|
|
546
|
-
import { Transactional, InjectQuerier, type Querier } from 'uql-orm';
|
|
547
|
-
|
|
548
|
-
export class UserService {
|
|
549
|
-
@Transactional()
|
|
550
|
-
async register({picture, ...user}: UserProfile, @InjectQuerier() querier?: Querier) {
|
|
551
|
-
const userId = await querier.insertOne(User, user);
|
|
552
|
-
await querier.insertOne(Profile, { userId, picture });
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
#### Option C: Imperative
|
|
558
|
-
|
|
559
|
-
For granular control over the transaction lifecycle, manage `begin`, `commit`, `rollback`, and `release` yourself.
|
|
560
|
-
|
|
561
|
-
```ts
|
|
562
|
-
const querier = await pool.getQuerier();
|
|
563
|
-
try {
|
|
564
|
-
await querier.beginTransaction();
|
|
565
|
-
|
|
566
|
-
const userId = await querier.insertOne(User, { name: '...' });
|
|
567
|
-
await querier.insertOne(Profile, { userId, picture: '...' });
|
|
568
|
-
|
|
569
|
-
await querier.commitTransaction();
|
|
570
|
-
} catch (error) {
|
|
571
|
-
await querier.rollbackTransaction();
|
|
572
|
-
throw error;
|
|
573
|
-
} finally {
|
|
574
|
-
await querier.release();
|
|
575
|
-
}
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
## 5. Migrations & Synchronization
|
|
106
|
+
## Migrations
|
|
579
107
|
|
|
580
|
-
|
|
108
|
+
Entity-first migrations: modify TypeScript classes, UQL auto-generates DDL by diffing code against the live database:
|
|
581
109
|
|
|
582
110
|
```bash
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
npx uql-migrate
|
|
586
|
-
|
|
587
|
-
# 3. Review and apply
|
|
588
|
-
npx uql-migrate up
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
> **Note:** Keep entities as the source of truth to minimize drift between code and database schema.
|
|
592
|
-
|
|
593
|
-
**Generated `generate:entities` files** emit **one `await querier.run("…")` per SQL statement** (table vs indexes, etc.), with the SQL passed as a **double-quoted string literal** (`JSON.stringify`) so dialects that quote identifiers with **backticks** (SQLite, LibSQL, MySQL-style) do not produce invalid TypeScript.
|
|
594
|
-
|
|
595
|
-
If you implement a **custom `SchemaGenerator`**, note that **`generateCreateTable`**, **`generateCreateTableFromNode`**, and **`generateCreateTableFromDefinition`** return **`string[]`** (one entry per `querier.run`). Use **`.join('\n')`** only when you need a single combined script. See the **[changelog](CHANGELOG.md)** for **0.8.2**.
|
|
596
|
-
|
|
597
|
-
**Advanced:** custom tools can use **`acquireQuerierForMigrations(pool)`** from **`uql-orm/migrate`** to match the same connection choice as **`Migrator`** and **`DatabaseMigrationStorage`** (including optional **`pool.getMigrationQuerier`**).
|
|
598
|
-
|
|
599
|
-
### 1. Unified Configuration
|
|
600
|
-
|
|
601
|
-
Reuse the same `uql.config.ts` for your app and the CLI to ensure consistent settings (naming strategies, entities, pool):
|
|
602
|
-
|
|
603
|
-
```ts
|
|
604
|
-
// uql.config.ts
|
|
605
|
-
import type { Config } from 'uql-orm';
|
|
606
|
-
import { PgQuerierPool } from 'uql-orm/postgres';
|
|
607
|
-
import { User, Profile, Post } from './entities';
|
|
608
|
-
|
|
609
|
-
export default {
|
|
610
|
-
pool: new PgQuerierPool({ /* ... */ }),
|
|
611
|
-
entities: [User, Profile, Post],
|
|
612
|
-
migrationsPath: './migrations',
|
|
613
|
-
} satisfies Config;
|
|
111
|
+
npx uql-migrate generate:entities add_user_nickname # generate from entities
|
|
112
|
+
npx uql-migrate up # apply
|
|
113
|
+
npx uql-migrate drift:check # detect drift
|
|
614
114
|
```
|
|
615
115
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
Use the CLI to manage your database schema evolution.
|
|
619
|
-
|
|
620
|
-
| Command | Description |
|
|
621
|
-
| :--- | :--- |
|
|
622
|
-
| `generate:entities <name>` | **Auto-generates** a migration by diffing your entities against the current DB schema. |
|
|
623
|
-
| `generate <name>` | Creates an empty timestamped file for **manual** SQL migrations (e.g., data backfills). |
|
|
624
|
-
| `generate:from-db` | **Scaffolds Entities** from an existing database. Includes **Smart Relation Detection**. |
|
|
625
|
-
| `drift:check` | **Drift Detection**: Compares your defined entities against the actual database schema and reports discrepancies. |
|
|
626
|
-
| `up` | Applies all pending migrations. |
|
|
627
|
-
| `down` | Rolls back the last applied migration batch. |
|
|
628
|
-
| `status` | Shows which migrations have been executed and which are pending. |
|
|
629
|
-
|
|
630
|
-
#### Usage Examples
|
|
631
|
-
|
|
632
|
-
```bash
|
|
633
|
-
# 1. Auto-generate schema changes from your entities
|
|
634
|
-
npx uql-migrate generate:entities add_profile_table
|
|
635
|
-
|
|
636
|
-
# 2. Apply changes
|
|
637
|
-
npx uql-migrate up
|
|
638
|
-
|
|
639
|
-
# 3. Check for schema drift (Production Safety)
|
|
640
|
-
npx uql-migrate drift:check
|
|
641
|
-
|
|
642
|
-
# 4. Scaffold entities from an existing DB (Legacy Adoption)
|
|
643
|
-
npx uql-migrate generate:from-db --output ./src/entities
|
|
644
|
-
|
|
645
|
-
# 5. Create a manual migration (for data backfills or custom SQL)
|
|
646
|
-
npx uql-migrate generate seed_default_roles
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
> **Bun Users**: If your `uql.config.ts` uses TypeScript path aliases (e.g., `~app/...`), run migrations with the `--bun` flag to ensure proper resolution:
|
|
650
|
-
> ```bash
|
|
651
|
-
> bun run --bun uql-migrate status
|
|
652
|
-
> ```
|
|
653
|
-
> Or add a script to your `package.json`: `"uql": "bun run --bun uql-migrate"`, then run commands like, e.g., `bun run uql status`.
|
|
654
|
-
|
|
655
|
-
### 3. AutoSync (Development)
|
|
656
|
-
|
|
657
|
-
Keep your schema in sync without manual migrations. It is **safe by default**: in safe mode (default), it adds new tables/columns and blocks destructive changes (e.g., dropping a column or changing a `VARCHAR` to an `INTEGER`). Blocked actions are logged so you can migrate them manually.
|
|
658
|
-
|
|
659
|
-
**New Capabilities (v3.8+):**
|
|
660
|
-
|
|
661
|
-
* **Schema AST Engine**: Uses a graph-based representation of your schema for 100% accurate diffing, handling circular dependencies and correct topological sort orders for table creation/dropping.
|
|
662
|
-
* **Smart Relation Detection**: When generating entities from an existing DB, UQL automatically detects relationships (OneToOne, ManyToMany) via foreign key structures and naming conventions (`user_id` -> `User`).
|
|
663
|
-
* **Bidirectional Index Sync**: Indexes defined in `@Field({ index: true })` or `@Index()` are synced to the DB, and indexes found in the DB are reflected in generated entities.
|
|
664
|
-
|
|
665
|
-
> **Important**: For `autoSync` to detect your entities, they must be **loaded** (imported) before calling `autoSync`.
|
|
666
|
-
|
|
667
|
-
**Using Your Config (Recommended)**
|
|
668
|
-
|
|
669
|
-
If you follow the [unified configuration](#1-unified-configuration) pattern, your entities are already imported. Simply reuse it:
|
|
670
|
-
|
|
671
|
-
```ts
|
|
672
|
-
import { Migrator } from 'uql-orm/migrate';
|
|
673
|
-
import config from './uql.config.js';
|
|
674
|
-
|
|
675
|
-
const migrator = new Migrator(config.pool, {
|
|
676
|
-
entities: config.entities,
|
|
677
|
-
});
|
|
678
|
-
await migrator.autoSync({ logging: true });
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
**Explicit Entities**
|
|
682
|
-
|
|
683
|
-
Alternatively, pass entities directly if you want to be explicit about which entities to sync:
|
|
684
|
-
|
|
685
|
-
```ts
|
|
686
|
-
import { Migrator } from 'uql-orm/migrate';
|
|
687
|
-
import { User, Profile, Post } from './entities/index.js';
|
|
688
|
-
|
|
689
|
-
const migrator = new Migrator(pool, {
|
|
690
|
-
entities: [User, Profile, Post],
|
|
691
|
-
});
|
|
692
|
-
await migrator.autoSync({ logging: true });
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
> **Note:** In development, `autoSync` accelerates iteration while still protecting data by blocking destructive schema changes.
|
|
696
|
-
|
|
697
|
-
## 6. Operations
|
|
698
|
-
|
|
699
|
-
### 6.1 Logging & Monitoring
|
|
700
|
-
|
|
701
|
-
UQL includes a structured logging system for query visibility and performance monitoring.
|
|
702
|
-
|
|
703
|
-
### Log Levels
|
|
704
|
-
|
|
705
|
-
| Level | Description |
|
|
706
|
-
| :-------------------- | :-------------------------------------------------------------------------------------- |
|
|
707
|
-
| `query` | **Standard Queries**: Beautifully formatted SQL/Command logs with execution time. |
|
|
708
|
-
| `slowQuery` | **Bottleneck Alerts**: Dedicated logging for queries exceeding your threshold. Use `logParams: false` to omit sensitive data. |
|
|
709
|
-
| `error` / `warn` | **System Health**: Detailed error traces and potential issue warnings. |
|
|
710
|
-
| `migration` | **Audit Trail**: Step-by-step history of schema changes. |
|
|
711
|
-
| `skippedMigration` | **Safety**: Logs blocked unsafe schema changes during autoSync. |
|
|
712
|
-
| `schema` / `info` | **Lifecycle**: Informative logs about ORM initialization and sync events. |
|
|
713
|
-
|
|
714
|
-
### Visual Feedback
|
|
715
|
-
|
|
716
|
-
The `DefaultLogger` provides high-contrast, colored output for quick debugging:
|
|
717
|
-
|
|
718
|
-
```text
|
|
719
|
-
query: SELECT * FROM "user" WHERE "id" = $1 -- [123] [2ms]
|
|
720
|
-
slow query: UPDATE "post" SET "title" = $1 -- ["New Title"] [1250ms]
|
|
721
|
-
error: Failed to connect to database: Connection timeout
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
> **Note:** In production, keep logs lean with `logger: ['error', 'warn', 'slowQuery']`.
|
|
725
|
-
|
|
726
|
-
Learn more about UQL at [uql-orm.dev](https://uql-orm.dev) for details on:
|
|
116
|
+
Safe `autoSync()` mode adds new tables/columns and blocks destructive changes in development.
|
|
727
117
|
|
|
728
|
-
|
|
729
|
-
- [Aggregate Queries (GROUP BY, HAVING, DISTINCT)](https://uql-orm.dev/querying/aggregate)
|
|
730
|
-
- [Semantic Search (Vector Similarity)](https://uql-orm.dev/querying/semantic-search)
|
|
731
|
-
- [Relationship Mapping (1-1, 1-M, M-M)](https://uql-orm.dev/querying/relations)
|
|
732
|
-
- [Lifecycle Hooks](https://uql-orm.dev/entities/lifecycle-hooks)
|
|
733
|
-
- [Soft Deletes & Auditing](https://uql-orm.dev/entities/soft-delete)
|
|
734
|
-
- [Database Migration & Syncing](https://uql-orm.dev/migrations)
|
|
118
|
+
> [Migrations](https://uql-orm.dev/migrations)
|
|
735
119
|
|
|
736
|
-
|
|
120
|
+
---
|
|
737
121
|
|
|
738
|
-
|
|
122
|
+
## Made with UQL
|
|
739
123
|
|
|
740
|
-
|
|
741
|
-
- **Core Dialect Logic**: The foundation of our context-aware SQL generation in [abstractSqlDialect.ts](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/dialect/abstractSqlDialect.ts).
|
|
742
|
-
- **Comprehensive Test Suite**:
|
|
743
|
-
- [Abstract SQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/dialect/abstractSqlDialect-spec.ts): Base test suite for all dialects.
|
|
744
|
-
- [PostgreSQL](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/postgres/postgresDialect.spec.ts) \| [MySQL](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/mysql/mysqlDialect.spec.ts) \| [SQLite](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/sqlite/sqliteDialect.spec.ts) specs.
|
|
745
|
-
- [Querier Integration Tests](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/querier/abstractSqlQuerier-spec.ts): SQL generation & connection management tests.
|
|
124
|
+
### [Variability.ai](https://variability.ai)
|
|
746
125
|
|
|
747
|
-
|
|
126
|
+
AI meeting recorder and video summarizer for Zoom, Meet, Teams, and more. Generates instant summaries with action items in 45+ languages.
|
|
748
127
|
|
|
749
|
-
|
|
128
|
+
[](https://uql-orm.dev)
|