uql-orm 0.20.2 → 0.22.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 +47 -110
- package/dist/browser/http/bus.d.ts +0 -1
- package/dist/browser/http/bus.js +0 -1
- package/dist/browser/http/http.d.ts +0 -1
- package/dist/browser/http/http.js +0 -1
- package/dist/browser/http/index.d.ts +0 -1
- package/dist/browser/http/index.js +0 -1
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/index.js +0 -1
- package/dist/browser/options.d.ts +0 -1
- package/dist/browser/options.js +0 -1
- package/dist/browser/querier/httpQuerier.d.ts +0 -1
- package/dist/browser/querier/httpQuerier.js +0 -1
- package/dist/browser/querier/index.d.ts +0 -1
- package/dist/browser/querier/index.js +0 -1
- package/dist/browser/type/clientQuerier.d.ts +0 -1
- package/dist/browser/type/clientQuerier.js +0 -1
- package/dist/browser/type/clientQuerierPool.d.ts +0 -1
- package/dist/browser/type/clientQuerierPool.js +0 -1
- package/dist/browser/type/index.d.ts +0 -1
- package/dist/browser/type/index.js +0 -1
- package/dist/browser/type/request.d.ts +0 -1
- package/dist/browser/type/request.js +0 -1
- package/dist/browser/uql-browser.min.js +2 -2
- package/dist/browser/uql-browser.min.js.map +1 -1
- package/dist/bunSql/bunSql.util.d.ts +0 -1
- package/dist/bunSql/bunSql.util.js +0 -1
- package/dist/bunSql/bunSqlCockroachDialect.d.ts +2 -3
- package/dist/bunSql/bunSqlCockroachDialect.js +4 -11
- package/dist/bunSql/bunSqlPostgresDialect.d.ts +2 -3
- package/dist/bunSql/bunSqlPostgresDialect.js +4 -11
- package/dist/bunSql/bunSqlQuerier.d.ts +0 -1
- package/dist/bunSql/bunSqlQuerier.js +0 -1
- package/dist/bunSql/bunSqlQuerierPool.d.ts +0 -1
- package/dist/bunSql/bunSqlQuerierPool.js +0 -1
- package/dist/bunSql/bunSqliteDialect.d.ts +0 -1
- package/dist/bunSql/bunSqliteDialect.js +0 -1
- package/dist/bunSql/index.d.ts +0 -1
- package/dist/bunSql/index.js +0 -1
- package/dist/cockroachdb/cockroachDialect.d.ts +20 -5
- package/dist/cockroachdb/cockroachDialect.js +33 -19
- package/dist/cockroachdb/crdbQuerier.d.ts +0 -1
- package/dist/cockroachdb/crdbQuerier.js +0 -1
- package/dist/cockroachdb/crdbQuerierPool.d.ts +0 -1
- package/dist/cockroachdb/crdbQuerierPool.js +0 -1
- package/dist/cockroachdb/index.d.ts +0 -1
- package/dist/cockroachdb/index.js +0 -1
- package/dist/context/context.browser.d.ts +0 -1
- package/dist/context/context.browser.js +0 -1
- package/dist/context/context.d.ts +0 -1
- package/dist/context/context.js +0 -1
- package/dist/context/securityError.d.ts +0 -1
- package/dist/context/securityError.js +0 -1
- package/dist/d1/d1Querier.d.ts +4 -4
- package/dist/d1/d1Querier.js +0 -4
- package/dist/d1/d1QuerierPool.d.ts +0 -1
- package/dist/d1/d1QuerierPool.js +0 -1
- package/dist/d1/d1SqliteDialect.d.ts +7 -1
- package/dist/d1/d1SqliteDialect.js +9 -1
- package/dist/d1/index.d.ts +0 -1
- package/dist/d1/index.js +0 -1
- package/dist/dialect/abstractDialect.d.ts +21 -5
- package/dist/dialect/abstractDialect.js +26 -5
- package/dist/dialect/abstractSqlDialect.d.ts +57 -17
- package/dist/dialect/abstractSqlDialect.js +182 -159
- package/dist/dialect/index.d.ts +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/dialect/indexSqlDialect.d.ts +57 -0
- package/dist/dialect/indexSqlDialect.js +101 -0
- package/dist/dialect/jsonArrayElemMatchUtils.d.ts +0 -1
- package/dist/dialect/jsonArrayElemMatchUtils.js +0 -1
- package/dist/dialect/jsonSql.d.ts +0 -1
- package/dist/dialect/jsonSql.js +1 -2
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +16 -2
- package/dist/dialect/mysqlLikeSqlDialect.js +34 -5
- package/dist/dialect/pgLikeSqlDialect.d.ts +34 -16
- package/dist/dialect/pgLikeSqlDialect.js +94 -71
- package/dist/dialect/queryContext.d.ts +0 -1
- package/dist/dialect/queryContext.js +0 -1
- package/dist/dialect/vectorCast.d.ts +32 -0
- package/dist/dialect/vectorCast.js +41 -0
- package/dist/dialect/vectorSqlDialect.d.ts +11 -5
- package/dist/dialect/vectorSqlDialect.js +19 -9
- package/dist/entity/decorator/entity.d.ts +0 -1
- package/dist/entity/decorator/entity.js +0 -1
- package/dist/entity/decorator/field.d.ts +0 -1
- package/dist/entity/decorator/field.js +0 -1
- package/dist/entity/decorator/filter.d.ts +0 -1
- package/dist/entity/decorator/filter.js +0 -1
- package/dist/entity/decorator/hook.d.ts +0 -1
- package/dist/entity/decorator/hook.js +0 -1
- package/dist/entity/decorator/id.d.ts +0 -1
- package/dist/entity/decorator/id.js +0 -1
- package/dist/entity/decorator/index-decorator.d.ts +2 -10
- package/dist/entity/decorator/index-decorator.js +0 -1
- package/dist/entity/decorator/index.d.ts +0 -1
- package/dist/entity/decorator/index.js +0 -1
- package/dist/entity/decorator/relation.d.ts +0 -1
- package/dist/entity/decorator/relation.js +0 -1
- package/dist/entity/index.d.ts +0 -1
- package/dist/entity/index.js +0 -1
- package/dist/entity/metadata/definition.d.ts +5 -6
- package/dist/entity/metadata/definition.js +10 -6
- package/dist/express/index.d.ts +0 -1
- package/dist/express/index.js +0 -1
- package/dist/express/querierMiddleware.d.ts +0 -1
- package/dist/express/querierMiddleware.js +0 -1
- package/dist/http/contract.d.ts +0 -1
- package/dist/http/contract.js +0 -1
- package/dist/http/fetchHandler.d.ts +0 -1
- package/dist/http/fetchHandler.js +0 -1
- package/dist/http/handler.d.ts +0 -1
- package/dist/http/handler.js +0 -1
- package/dist/http/index.d.ts +0 -1
- package/dist/http/index.js +0 -1
- package/dist/http/query.d.ts +0 -1
- package/dist/http/query.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/libsql/index.d.ts +0 -1
- package/dist/libsql/index.js +0 -1
- package/dist/libsql/libsqlDialect.d.ts +12 -3
- package/dist/libsql/libsqlDialect.js +14 -3
- package/dist/libsql/libsqlQuerier.d.ts +9 -23
- package/dist/libsql/libsqlQuerier.js +9 -78
- package/dist/libsql/libsqlQuerierPool.d.ts +10 -9
- package/dist/libsql/libsqlQuerierPool.js +17 -16
- package/dist/maria/index.d.ts +0 -1
- package/dist/maria/index.js +0 -1
- package/dist/maria/mariaDialect.d.ts +26 -5
- package/dist/maria/mariaDialect.js +54 -16
- package/dist/maria/mariadbQuerier.d.ts +0 -1
- package/dist/maria/mariadbQuerier.js +0 -1
- package/dist/maria/mariadbQuerierPool.d.ts +0 -1
- package/dist/maria/mariadbQuerierPool.js +0 -1
- package/dist/migrate/acquireQuerierForMigrations.d.ts +0 -1
- package/dist/migrate/acquireQuerierForMigrations.js +0 -1
- package/dist/migrate/assertCliConfig.d.ts +0 -1
- package/dist/migrate/assertCliConfig.js +0 -1
- package/dist/migrate/bin.d.ts +0 -1
- package/dist/migrate/bin.js +0 -1
- package/dist/migrate/builder/columnBuilder.d.ts +0 -1
- package/dist/migrate/builder/columnBuilder.js +0 -1
- package/dist/migrate/builder/expressions.d.ts +0 -1
- package/dist/migrate/builder/expressions.js +0 -1
- package/dist/migrate/builder/index.d.ts +0 -1
- package/dist/migrate/builder/index.js +0 -1
- package/dist/migrate/builder/migrationBuilder.d.ts +9 -30
- package/dist/migrate/builder/migrationBuilder.js +58 -77
- package/dist/migrate/builder/splitSqlStatements.d.ts +0 -3
- package/dist/migrate/builder/splitSqlStatements.js +0 -3
- package/dist/migrate/builder/tableBuilder.d.ts +12 -3
- package/dist/migrate/builder/tableBuilder.js +71 -120
- package/dist/migrate/builder/types.d.ts +30 -42
- package/dist/migrate/builder/types.js +0 -1
- package/dist/migrate/cli-config.d.ts +0 -1
- package/dist/migrate/cli-config.js +9 -5
- package/dist/migrate/cli.d.ts +3 -3
- package/dist/migrate/cli.js +21 -49
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -5
- package/dist/migrate/codegen/entityCodeGenerator.js +5 -64
- package/dist/migrate/codegen/fieldOptionsSource.d.ts +10 -0
- package/dist/migrate/codegen/fieldOptionsSource.js +55 -0
- package/dist/migrate/codegen/index.d.ts +0 -3
- package/dist/migrate/codegen/index.js +0 -5
- package/dist/migrate/codegen/migrationFile.d.ts +0 -1
- package/dist/migrate/codegen/migrationFile.js +0 -1
- package/dist/migrate/codegen/smartRelationDetector.d.ts +0 -1
- package/dist/migrate/codegen/smartRelationDetector.js +0 -1
- package/dist/migrate/drift/driftDetector.d.ts +0 -1
- package/dist/migrate/drift/driftDetector.js +0 -1
- package/dist/migrate/drift/index.d.ts +0 -1
- package/dist/migrate/drift/index.js +0 -1
- package/dist/migrate/generator/indexNodeToSchema.d.ts +9 -0
- package/dist/migrate/generator/indexNodeToSchema.js +14 -0
- package/dist/migrate/generator/mongoCommand.d.ts +57 -0
- package/dist/migrate/generator/mongoCommand.js +26 -0
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +9 -21
- package/dist/migrate/generator/mongoSchemaGenerator.js +40 -83
- package/dist/migrate/index.d.ts +0 -2
- package/dist/migrate/index.js +0 -2
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +25 -11
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +46 -33
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -2
- package/dist/migrate/introspection/baseSqlIntrospector.js +3 -13
- package/dist/migrate/introspection/index.d.ts +0 -1
- package/dist/migrate/introspection/index.js +0 -1
- package/dist/migrate/introspection/mongoIntrospector.d.ts +0 -1
- package/dist/migrate/introspection/mongoIntrospector.js +2 -3
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +5 -9
- package/dist/migrate/introspection/mysqlIntrospector.js +4 -11
- package/dist/migrate/introspection/postgresIntrospector.d.ts +5 -9
- package/dist/migrate/introspection/postgresIntrospector.js +4 -11
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +6 -6
- package/dist/migrate/introspection/sqliteIntrospector.js +26 -19
- package/dist/migrate/migrator.d.ts +23 -4
- package/dist/migrate/migrator.js +57 -70
- package/dist/migrate/schemaGenerator.d.ts +26 -38
- package/dist/migrate/schemaGenerator.js +69 -175
- package/dist/migrate/schemaGeneratorAsync.d.ts +2 -3
- package/dist/migrate/schemaGeneratorAsync.js +3 -4
- package/dist/migrate/storage/databaseStorage.d.ts +0 -1
- package/dist/migrate/storage/databaseStorage.js +4 -5
- package/dist/migrate/storage/index.d.ts +0 -1
- package/dist/migrate/storage/index.js +0 -1
- package/dist/migrate/storage/jsonStorage.d.ts +0 -1
- package/dist/migrate/storage/jsonStorage.js +0 -1
- package/dist/mongo/index.d.ts +0 -1
- package/dist/mongo/index.js +0 -1
- package/dist/mongo/mongoDialect.d.ts +93 -5
- package/dist/mongo/mongoDialect.js +315 -83
- package/dist/mongo/mongodbNativeDialect.d.ts +0 -1
- package/dist/mongo/mongodbNativeDialect.js +0 -1
- package/dist/mongo/mongodbQuerier.d.ts +5 -1
- package/dist/mongo/mongodbQuerier.js +61 -19
- package/dist/mongo/mongodbQuerierPool.d.ts +0 -1
- package/dist/mongo/mongodbQuerierPool.js +0 -1
- package/dist/mysql/index.d.ts +0 -1
- package/dist/mysql/index.js +0 -1
- package/dist/mysql/mysql2Dialect.d.ts +0 -1
- package/dist/mysql/mysql2Dialect.js +0 -1
- package/dist/mysql/mysql2Querier.d.ts +0 -1
- package/dist/mysql/mysql2Querier.js +0 -1
- package/dist/mysql/mysql2QuerierPool.d.ts +0 -1
- package/dist/mysql/mysql2QuerierPool.js +0 -1
- package/dist/mysql/mysqlDialect.d.ts +8 -1
- package/dist/mysql/mysqlDialect.js +13 -1
- package/dist/namingStrategy/defaultNamingStrategy.d.ts +0 -1
- package/dist/namingStrategy/defaultNamingStrategy.js +0 -1
- package/dist/namingStrategy/index.d.ts +0 -1
- package/dist/namingStrategy/index.js +0 -1
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts +0 -1
- package/dist/namingStrategy/snakeCaseNamingStrategy.js +0 -1
- package/dist/neon/index.d.ts +0 -1
- package/dist/neon/index.js +0 -1
- package/dist/neon/neonDialect.d.ts +0 -1
- package/dist/neon/neonDialect.js +0 -1
- package/dist/neon/neonQuerier.d.ts +0 -1
- package/dist/neon/neonQuerier.js +0 -1
- package/dist/neon/neonQuerierPool.d.ts +0 -1
- package/dist/neon/neonQuerierPool.js +0 -1
- package/dist/nestjs/index.d.ts +0 -1
- package/dist/nestjs/index.js +0 -1
- package/dist/nestjs/uqlContextInterceptor.d.ts +0 -1
- package/dist/nestjs/uqlContextInterceptor.js +9 -2
- package/dist/nestjs/uqlModule.d.ts +0 -1
- package/dist/nestjs/uqlModule.js +12 -2
- package/dist/options.d.ts +0 -1
- package/dist/options.js +0 -1
- package/dist/postgres/abstractPgQuerier.d.ts +0 -1
- package/dist/postgres/abstractPgQuerier.js +0 -1
- package/dist/postgres/abstractPgQuerierPool.d.ts +0 -1
- package/dist/postgres/abstractPgQuerierPool.js +0 -1
- package/dist/postgres/index.d.ts +0 -1
- package/dist/postgres/index.js +0 -1
- package/dist/postgres/pgDialect.d.ts +0 -1
- package/dist/postgres/pgDialect.js +0 -1
- package/dist/postgres/pgQuerier.d.ts +0 -1
- package/dist/postgres/pgQuerier.js +0 -1
- package/dist/postgres/pgQuerierPool.d.ts +0 -1
- package/dist/postgres/pgQuerierPool.js +0 -1
- package/dist/postgres/postgresDialect.d.ts +0 -1
- package/dist/postgres/postgresDialect.js +0 -1
- package/dist/postgres/postgresWireDriverCapabilities.d.ts +0 -1
- package/dist/postgres/postgresWireDriverCapabilities.js +0 -1
- package/dist/querier/abstractPoolQuerier.d.ts +0 -1
- package/dist/querier/abstractPoolQuerier.js +0 -1
- package/dist/querier/abstractQuerier.d.ts +0 -1
- package/dist/querier/abstractQuerier.js +9 -2
- package/dist/querier/abstractQuerierPool.d.ts +0 -1
- package/dist/querier/abstractQuerierPool.js +0 -1
- package/dist/querier/abstractSqlQuerier.d.ts +0 -1
- package/dist/querier/abstractSqlQuerier.js +9 -2
- package/dist/querier/abstractSqlQuerierPool.d.ts +0 -1
- package/dist/querier/abstractSqlQuerierPool.js +0 -1
- package/dist/querier/decorator/index.d.ts +0 -1
- package/dist/querier/decorator/index.js +0 -1
- package/dist/querier/decorator/injectQuerier.d.ts +0 -1
- package/dist/querier/decorator/injectQuerier.js +0 -1
- package/dist/querier/decorator/log.d.ts +0 -1
- package/dist/querier/decorator/log.js +0 -1
- package/dist/querier/decorator/serialized.d.ts +0 -1
- package/dist/querier/decorator/serialized.js +0 -1
- package/dist/querier/decorator/transactional.d.ts +0 -1
- package/dist/querier/decorator/transactional.js +0 -1
- package/dist/querier/index.d.ts +0 -1
- package/dist/querier/index.js +0 -1
- package/dist/schema/canonicalType.d.ts +14 -13
- package/dist/schema/canonicalType.js +41 -44
- package/dist/schema/index.d.ts +1 -2
- package/dist/schema/index.js +0 -1
- package/dist/schema/schemaAST.d.ts +0 -1
- package/dist/schema/schemaAST.js +0 -1
- package/dist/schema/schemaASTBuilder.d.ts +8 -2
- package/dist/schema/schemaASTBuilder.js +56 -48
- package/dist/schema/schemaASTDiffer.d.ts +0 -1
- package/dist/schema/schemaASTDiffer.js +0 -1
- package/dist/schema/types.d.ts +10 -38
- package/dist/schema/types.js +0 -1
- package/dist/sqlite/abstractSqliteQuerier.d.ts +39 -1
- package/dist/sqlite/abstractSqliteQuerier.js +44 -1
- package/dist/sqlite/bunSqliteAdapter.bun.d.ts +26 -0
- package/dist/sqlite/bunSqliteAdapter.bun.js +25 -0
- package/dist/sqlite/hranaQuerier.d.ts +54 -0
- package/dist/sqlite/hranaQuerier.js +90 -0
- package/dist/sqlite/hranaQuerierPool.d.ts +21 -0
- package/dist/sqlite/hranaQuerierPool.js +25 -0
- package/dist/sqlite/index.d.ts +2 -2
- package/dist/sqlite/index.js +2 -2
- package/dist/sqlite/sqliteDialect.d.ts +18 -5
- package/dist/sqlite/sqliteDialect.js +24 -25
- package/dist/sqlite/sqliteQuerier.d.ts +16 -10
- package/dist/sqlite/sqliteQuerier.js +4 -28
- package/dist/sqlite/sqliteQuerierPool.d.ts +14 -5
- package/dist/sqlite/sqliteQuerierPool.js +16 -6
- package/dist/turso/index.d.ts +3 -0
- package/dist/turso/index.js +3 -0
- package/dist/turso/local.d.ts +3 -0
- package/dist/turso/local.js +3 -0
- package/dist/turso/tursoDialect.d.ts +15 -0
- package/dist/turso/tursoDialect.js +18 -0
- package/dist/turso/tursoLocalQuerier.d.ts +25 -0
- package/dist/turso/tursoLocalQuerier.js +20 -0
- package/dist/turso/tursoLocalQuerierPool.d.ts +32 -0
- package/dist/turso/tursoLocalQuerierPool.js +39 -0
- package/dist/turso/tursoQuerier.d.ts +10 -0
- package/dist/turso/tursoQuerier.js +10 -0
- package/dist/turso/tursoQuerierPool.d.ts +39 -0
- package/dist/turso/tursoQuerierPool.js +38 -0
- package/dist/type/config.d.ts +0 -7
- package/dist/type/config.js +0 -1
- package/dist/type/dialect.d.ts +12 -5
- package/dist/type/dialect.js +7 -2
- package/dist/type/entity.d.ts +66 -6
- package/dist/type/entity.js +0 -1
- package/dist/type/index.d.ts +0 -1
- package/dist/type/index.js +0 -1
- package/dist/type/logger.d.ts +0 -1
- package/dist/type/logger.js +0 -1
- package/dist/type/migration.d.ts +32 -24
- package/dist/type/migration.js +0 -1
- package/dist/type/migratorDialect.d.ts +0 -1
- package/dist/type/migratorDialect.js +0 -1
- package/dist/type/namingStrategy.d.ts +0 -1
- package/dist/type/namingStrategy.js +0 -1
- package/dist/type/querier.d.ts +0 -1
- package/dist/type/querier.js +0 -1
- package/dist/type/querierPool.d.ts +0 -1
- package/dist/type/querierPool.js +0 -1
- package/dist/type/query.d.ts +0 -1
- package/dist/type/query.js +0 -1
- package/dist/type/queryAggregate.d.ts +0 -1
- package/dist/type/queryAggregate.js +0 -1
- package/dist/type/queryRaw.d.ts +0 -1
- package/dist/type/queryRaw.js +0 -1
- package/dist/type/queryWhere.d.ts +0 -1
- package/dist/type/queryWhere.js +0 -1
- package/dist/type/universalQuerier.d.ts +0 -1
- package/dist/type/universalQuerier.js +0 -1
- package/dist/type/utility.d.ts +0 -1
- package/dist/type/utility.js +0 -1
- package/dist/type/vector.d.ts +5 -3
- package/dist/type/vector.js +0 -1
- package/dist/util/dialect.util.d.ts +8 -2
- package/dist/util/dialect.util.js +16 -1
- package/dist/util/field.util.d.ts +0 -1
- package/dist/util/field.util.js +0 -1
- package/dist/util/filters.util.d.ts +0 -1
- package/dist/util/filters.util.js +0 -1
- package/dist/util/hook.util.d.ts +0 -1
- package/dist/util/hook.util.js +0 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +1 -1
- package/dist/util/indexColumn.util.d.ts +6 -0
- package/dist/util/indexColumn.util.js +26 -0
- package/dist/util/logger.d.ts +0 -1
- package/dist/util/logger.js +0 -1
- package/dist/util/object.util.d.ts +0 -1
- package/dist/util/object.util.js +0 -1
- package/dist/util/raw.d.ts +0 -1
- package/dist/util/raw.js +0 -1
- package/dist/util/relationQuery.util.d.ts +0 -1
- package/dist/util/relationQuery.util.js +0 -1
- package/dist/util/sql.util.d.ts +0 -1
- package/dist/util/sql.util.js +0 -1
- package/dist/util/sqlLiteral.d.ts +19 -0
- package/dist/util/sqlLiteral.js +108 -0
- package/dist/util/string.util.d.ts +0 -1
- package/dist/util/string.util.js +0 -1
- package/package.json +57 -27
- package/CHANGELOG.md +0 -1359
- package/dist/browser/http/bus.d.ts.map +0 -1
- package/dist/browser/http/bus.js.map +0 -1
- package/dist/browser/http/http.d.ts.map +0 -1
- package/dist/browser/http/http.js.map +0 -1
- package/dist/browser/http/index.d.ts.map +0 -1
- package/dist/browser/http/index.js.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/options.d.ts.map +0 -1
- package/dist/browser/options.js.map +0 -1
- package/dist/browser/querier/httpQuerier.d.ts.map +0 -1
- package/dist/browser/querier/httpQuerier.js.map +0 -1
- package/dist/browser/querier/index.d.ts.map +0 -1
- package/dist/browser/querier/index.js.map +0 -1
- package/dist/browser/type/clientQuerier.d.ts.map +0 -1
- package/dist/browser/type/clientQuerier.js.map +0 -1
- package/dist/browser/type/clientQuerierPool.d.ts.map +0 -1
- package/dist/browser/type/clientQuerierPool.js.map +0 -1
- package/dist/browser/type/index.d.ts.map +0 -1
- package/dist/browser/type/index.js.map +0 -1
- package/dist/browser/type/request.d.ts.map +0 -1
- package/dist/browser/type/request.js.map +0 -1
- package/dist/bunSql/bunSql.util.d.ts.map +0 -1
- package/dist/bunSql/bunSql.util.js.map +0 -1
- package/dist/bunSql/bunSqlCockroachDialect.d.ts.map +0 -1
- package/dist/bunSql/bunSqlCockroachDialect.js.map +0 -1
- package/dist/bunSql/bunSqlPostgresDialect.d.ts.map +0 -1
- package/dist/bunSql/bunSqlPostgresDialect.js.map +0 -1
- package/dist/bunSql/bunSqlQuerier.d.ts.map +0 -1
- package/dist/bunSql/bunSqlQuerier.js.map +0 -1
- package/dist/bunSql/bunSqlQuerierPool.d.ts.map +0 -1
- package/dist/bunSql/bunSqlQuerierPool.js.map +0 -1
- package/dist/bunSql/bunSqliteDialect.d.ts.map +0 -1
- package/dist/bunSql/bunSqliteDialect.js.map +0 -1
- package/dist/bunSql/index.d.ts.map +0 -1
- package/dist/bunSql/index.js.map +0 -1
- package/dist/cockroachdb/cockroachDialect.d.ts.map +0 -1
- package/dist/cockroachdb/cockroachDialect.js.map +0 -1
- package/dist/cockroachdb/crdbQuerier.d.ts.map +0 -1
- package/dist/cockroachdb/crdbQuerier.js.map +0 -1
- package/dist/cockroachdb/crdbQuerierPool.d.ts.map +0 -1
- package/dist/cockroachdb/crdbQuerierPool.js.map +0 -1
- package/dist/cockroachdb/index.d.ts.map +0 -1
- package/dist/cockroachdb/index.js.map +0 -1
- package/dist/context/context.browser.d.ts.map +0 -1
- package/dist/context/context.browser.js.map +0 -1
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/context.js.map +0 -1
- package/dist/context/securityError.d.ts.map +0 -1
- package/dist/context/securityError.js.map +0 -1
- package/dist/d1/d1Querier.d.ts.map +0 -1
- package/dist/d1/d1Querier.js.map +0 -1
- package/dist/d1/d1QuerierPool.d.ts.map +0 -1
- package/dist/d1/d1QuerierPool.js.map +0 -1
- package/dist/d1/d1SqliteDialect.d.ts.map +0 -1
- package/dist/d1/d1SqliteDialect.js.map +0 -1
- package/dist/d1/index.d.ts.map +0 -1
- package/dist/d1/index.js.map +0 -1
- package/dist/dialect/abstractDialect.d.ts.map +0 -1
- package/dist/dialect/abstractDialect.js.map +0 -1
- package/dist/dialect/abstractSqlDialect.d.ts.map +0 -1
- package/dist/dialect/abstractSqlDialect.js.map +0 -1
- package/dist/dialect/index.d.ts.map +0 -1
- package/dist/dialect/index.js.map +0 -1
- package/dist/dialect/jsonArrayElemMatchUtils.d.ts.map +0 -1
- package/dist/dialect/jsonArrayElemMatchUtils.js.map +0 -1
- package/dist/dialect/jsonSql.d.ts.map +0 -1
- package/dist/dialect/jsonSql.js.map +0 -1
- package/dist/dialect/mysqlLikeSqlDialect.d.ts.map +0 -1
- package/dist/dialect/mysqlLikeSqlDialect.js.map +0 -1
- package/dist/dialect/pgLikeSqlDialect.d.ts.map +0 -1
- package/dist/dialect/pgLikeSqlDialect.js.map +0 -1
- package/dist/dialect/queryContext.d.ts.map +0 -1
- package/dist/dialect/queryContext.js.map +0 -1
- package/dist/dialect/vectorSqlDialect.d.ts.map +0 -1
- package/dist/dialect/vectorSqlDialect.js.map +0 -1
- package/dist/entity/decorator/entity.d.ts.map +0 -1
- package/dist/entity/decorator/entity.js.map +0 -1
- package/dist/entity/decorator/field.d.ts.map +0 -1
- package/dist/entity/decorator/field.js.map +0 -1
- package/dist/entity/decorator/filter.d.ts.map +0 -1
- package/dist/entity/decorator/filter.js.map +0 -1
- package/dist/entity/decorator/hook.d.ts.map +0 -1
- package/dist/entity/decorator/hook.js.map +0 -1
- package/dist/entity/decorator/id.d.ts.map +0 -1
- package/dist/entity/decorator/id.js.map +0 -1
- package/dist/entity/decorator/index-decorator.d.ts.map +0 -1
- package/dist/entity/decorator/index-decorator.js.map +0 -1
- package/dist/entity/decorator/index.d.ts.map +0 -1
- package/dist/entity/decorator/index.js.map +0 -1
- package/dist/entity/decorator/relation.d.ts.map +0 -1
- package/dist/entity/decorator/relation.js.map +0 -1
- package/dist/entity/index.d.ts.map +0 -1
- package/dist/entity/index.js.map +0 -1
- package/dist/entity/metadata/definition.d.ts.map +0 -1
- 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 -16
- package/dist/entity/test-helpers.js.map +0 -1
- package/dist/express/index.d.ts.map +0 -1
- package/dist/express/index.js.map +0 -1
- package/dist/express/querierMiddleware.d.ts.map +0 -1
- package/dist/express/querierMiddleware.js.map +0 -1
- package/dist/http/contract.d.ts.map +0 -1
- package/dist/http/contract.js.map +0 -1
- package/dist/http/fetchHandler.d.ts.map +0 -1
- package/dist/http/fetchHandler.js.map +0 -1
- package/dist/http/handler.d.ts.map +0 -1
- package/dist/http/handler.js.map +0 -1
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js.map +0 -1
- package/dist/http/query.d.ts.map +0 -1
- package/dist/http/query.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/libsql/index.d.ts.map +0 -1
- package/dist/libsql/index.js.map +0 -1
- package/dist/libsql/libsqlDialect.d.ts.map +0 -1
- package/dist/libsql/libsqlDialect.js.map +0 -1
- package/dist/libsql/libsqlQuerier.d.ts.map +0 -1
- package/dist/libsql/libsqlQuerier.js.map +0 -1
- package/dist/libsql/libsqlQuerierPool.d.ts.map +0 -1
- package/dist/libsql/libsqlQuerierPool.js.map +0 -1
- package/dist/maria/index.d.ts.map +0 -1
- package/dist/maria/index.js.map +0 -1
- package/dist/maria/mariaDialect.d.ts.map +0 -1
- package/dist/maria/mariaDialect.js.map +0 -1
- package/dist/maria/mariadbQuerier.d.ts.map +0 -1
- package/dist/maria/mariadbQuerier.js.map +0 -1
- package/dist/maria/mariadbQuerierPool.d.ts.map +0 -1
- package/dist/maria/mariadbQuerierPool.js.map +0 -1
- package/dist/migrate/acquireQuerierForMigrations.d.ts.map +0 -1
- package/dist/migrate/acquireQuerierForMigrations.js.map +0 -1
- package/dist/migrate/assertCliConfig.d.ts.map +0 -1
- package/dist/migrate/assertCliConfig.js.map +0 -1
- package/dist/migrate/bin.d.ts.map +0 -1
- package/dist/migrate/bin.js.map +0 -1
- package/dist/migrate/builder/columnBuilder.d.ts.map +0 -1
- package/dist/migrate/builder/columnBuilder.js.map +0 -1
- package/dist/migrate/builder/expressions.d.ts.map +0 -1
- package/dist/migrate/builder/expressions.js.map +0 -1
- package/dist/migrate/builder/index.d.ts.map +0 -1
- package/dist/migrate/builder/index.js.map +0 -1
- package/dist/migrate/builder/migrationBuilder.d.ts.map +0 -1
- package/dist/migrate/builder/migrationBuilder.js.map +0 -1
- package/dist/migrate/builder/splitSqlStatements.d.ts.map +0 -1
- package/dist/migrate/builder/splitSqlStatements.js.map +0 -1
- package/dist/migrate/builder/tableBuilder.d.ts.map +0 -1
- package/dist/migrate/builder/tableBuilder.js.map +0 -1
- package/dist/migrate/builder/types.d.ts.map +0 -1
- package/dist/migrate/builder/types.js.map +0 -1
- package/dist/migrate/cli-config.d.ts.map +0 -1
- package/dist/migrate/cli-config.js.map +0 -1
- package/dist/migrate/cli.d.ts.map +0 -1
- package/dist/migrate/cli.js.map +0 -1
- package/dist/migrate/codegen/entityCodeGenerator.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/dist/migrate/codegen/migrationFile.js.map +0 -1
- package/dist/migrate/codegen/smartRelationDetector.d.ts.map +0 -1
- package/dist/migrate/codegen/smartRelationDetector.js.map +0 -1
- package/dist/migrate/drift/driftDetector.d.ts.map +0 -1
- package/dist/migrate/drift/driftDetector.js.map +0 -1
- package/dist/migrate/drift/index.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/migrate/generator/mongoSchemaGenerator.js.map +0 -1
- package/dist/migrate/index.d.ts.map +0 -1
- package/dist/migrate/index.js.map +0 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js.map +0 -1
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/baseSqlIntrospector.js.map +0 -1
- package/dist/migrate/introspection/index.d.ts.map +0 -1
- package/dist/migrate/introspection/index.js.map +0 -1
- package/dist/migrate/introspection/mongoIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/mongoIntrospector.js.map +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.js.map +0 -1
- package/dist/migrate/introspection/postgresIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/postgresIntrospector.js.map +0 -1
- package/dist/migrate/introspection/sqliteIntrospector.d.ts.map +0 -1
- package/dist/migrate/introspection/sqliteIntrospector.js.map +0 -1
- package/dist/migrate/migrator.d.ts.map +0 -1
- package/dist/migrate/migrator.js.map +0 -1
- package/dist/migrate/schemaGenerator.d.ts.map +0 -1
- package/dist/migrate/schemaGenerator.js.map +0 -1
- package/dist/migrate/schemaGeneratorAsync.d.ts.map +0 -1
- package/dist/migrate/schemaGeneratorAsync.js.map +0 -1
- package/dist/migrate/storage/databaseStorage.d.ts.map +0 -1
- package/dist/migrate/storage/databaseStorage.js.map +0 -1
- package/dist/migrate/storage/index.d.ts.map +0 -1
- package/dist/migrate/storage/index.js.map +0 -1
- package/dist/migrate/storage/jsonStorage.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/mongo/index.js.map +0 -1
- package/dist/mongo/mongoDialect.d.ts.map +0 -1
- package/dist/mongo/mongoDialect.js.map +0 -1
- package/dist/mongo/mongodbNativeDialect.d.ts.map +0 -1
- package/dist/mongo/mongodbNativeDialect.js.map +0 -1
- package/dist/mongo/mongodbQuerier.d.ts.map +0 -1
- package/dist/mongo/mongodbQuerier.js.map +0 -1
- package/dist/mongo/mongodbQuerierPool.d.ts.map +0 -1
- package/dist/mongo/mongodbQuerierPool.js.map +0 -1
- package/dist/mysql/index.d.ts.map +0 -1
- package/dist/mysql/index.js.map +0 -1
- package/dist/mysql/mysql2Dialect.d.ts.map +0 -1
- package/dist/mysql/mysql2Dialect.js.map +0 -1
- package/dist/mysql/mysql2Querier.d.ts.map +0 -1
- package/dist/mysql/mysql2Querier.js.map +0 -1
- package/dist/mysql/mysql2QuerierPool.d.ts.map +0 -1
- package/dist/mysql/mysql2QuerierPool.js.map +0 -1
- package/dist/mysql/mysqlDialect.d.ts.map +0 -1
- package/dist/mysql/mysqlDialect.js.map +0 -1
- package/dist/namingStrategy/defaultNamingStrategy.d.ts.map +0 -1
- package/dist/namingStrategy/defaultNamingStrategy.js.map +0 -1
- package/dist/namingStrategy/index.d.ts.map +0 -1
- package/dist/namingStrategy/index.js.map +0 -1
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts.map +0 -1
- package/dist/namingStrategy/snakeCaseNamingStrategy.js.map +0 -1
- package/dist/neon/index.d.ts.map +0 -1
- package/dist/neon/index.js.map +0 -1
- package/dist/neon/neonDialect.d.ts.map +0 -1
- package/dist/neon/neonDialect.js.map +0 -1
- package/dist/neon/neonQuerier.d.ts.map +0 -1
- package/dist/neon/neonQuerier.js.map +0 -1
- package/dist/neon/neonQuerierPool.d.ts.map +0 -1
- package/dist/neon/neonQuerierPool.js.map +0 -1
- package/dist/nestjs/index.d.ts.map +0 -1
- package/dist/nestjs/index.js.map +0 -1
- package/dist/nestjs/uqlContextInterceptor.d.ts.map +0 -1
- package/dist/nestjs/uqlContextInterceptor.js.map +0 -1
- package/dist/nestjs/uqlModule.d.ts.map +0 -1
- package/dist/nestjs/uqlModule.js.map +0 -1
- package/dist/options.d.ts.map +0 -1
- package/dist/options.js.map +0 -1
- package/dist/postgres/abstractPgQuerier.d.ts.map +0 -1
- package/dist/postgres/abstractPgQuerier.js.map +0 -1
- package/dist/postgres/abstractPgQuerierPool.d.ts.map +0 -1
- package/dist/postgres/abstractPgQuerierPool.js.map +0 -1
- package/dist/postgres/index.d.ts.map +0 -1
- package/dist/postgres/index.js.map +0 -1
- package/dist/postgres/pgDialect.d.ts.map +0 -1
- package/dist/postgres/pgDialect.js.map +0 -1
- package/dist/postgres/pgQuerier.d.ts.map +0 -1
- package/dist/postgres/pgQuerier.js.map +0 -1
- package/dist/postgres/pgQuerierPool.d.ts.map +0 -1
- package/dist/postgres/pgQuerierPool.js.map +0 -1
- package/dist/postgres/postgresDialect.d.ts.map +0 -1
- package/dist/postgres/postgresDialect.js.map +0 -1
- package/dist/postgres/postgresWireDriverCapabilities.d.ts.map +0 -1
- package/dist/postgres/postgresWireDriverCapabilities.js.map +0 -1
- package/dist/querier/abstractPoolQuerier.d.ts.map +0 -1
- package/dist/querier/abstractPoolQuerier.js.map +0 -1
- package/dist/querier/abstractQuerier.d.ts.map +0 -1
- package/dist/querier/abstractQuerier.js.map +0 -1
- package/dist/querier/abstractQuerierPool.d.ts.map +0 -1
- package/dist/querier/abstractQuerierPool.js.map +0 -1
- package/dist/querier/abstractSqlQuerier.d.ts.map +0 -1
- package/dist/querier/abstractSqlQuerier.js.map +0 -1
- package/dist/querier/abstractSqlQuerierPool.d.ts.map +0 -1
- package/dist/querier/abstractSqlQuerierPool.js.map +0 -1
- package/dist/querier/decorator/index.d.ts.map +0 -1
- package/dist/querier/decorator/index.js.map +0 -1
- package/dist/querier/decorator/injectQuerier.d.ts.map +0 -1
- package/dist/querier/decorator/injectQuerier.js.map +0 -1
- package/dist/querier/decorator/log.d.ts.map +0 -1
- package/dist/querier/decorator/log.js.map +0 -1
- package/dist/querier/decorator/serialized.d.ts.map +0 -1
- package/dist/querier/decorator/serialized.js.map +0 -1
- package/dist/querier/decorator/transactional.d.ts.map +0 -1
- package/dist/querier/decorator/transactional.js.map +0 -1
- package/dist/querier/index.d.ts.map +0 -1
- package/dist/querier/index.js.map +0 -1
- package/dist/schema/canonicalType.d.ts.map +0 -1
- package/dist/schema/canonicalType.js.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/schemaAST.d.ts.map +0 -1
- package/dist/schema/schemaAST.js.map +0 -1
- package/dist/schema/schemaASTBuilder.d.ts.map +0 -1
- package/dist/schema/schemaASTBuilder.js.map +0 -1
- package/dist/schema/schemaASTDiffer.d.ts.map +0 -1
- package/dist/schema/schemaASTDiffer.js.map +0 -1
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/schema/types.js.map +0 -1
- package/dist/sqlite/abstractSqliteQuerier.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/sqlite/index.js.map +0 -1
- package/dist/sqlite/sqliteDialect.d.ts.map +0 -1
- package/dist/sqlite/sqliteDialect.js.map +0 -1
- package/dist/sqlite/sqliteQuerier.d.ts.map +0 -1
- package/dist/sqlite/sqliteQuerier.js.map +0 -1
- package/dist/sqlite/sqliteQuerierPool.d.ts.map +0 -1
- package/dist/sqlite/sqliteQuerierPool.js.map +0 -1
- package/dist/type/config.d.ts.map +0 -1
- package/dist/type/config.js.map +0 -1
- package/dist/type/dialect.d.ts.map +0 -1
- package/dist/type/dialect.js.map +0 -1
- package/dist/type/entity.d.ts.map +0 -1
- package/dist/type/entity.js.map +0 -1
- package/dist/type/index.d.ts.map +0 -1
- package/dist/type/index.js.map +0 -1
- package/dist/type/logger.d.ts.map +0 -1
- package/dist/type/logger.js.map +0 -1
- package/dist/type/migration.d.ts.map +0 -1
- package/dist/type/migration.js.map +0 -1
- package/dist/type/migratorDialect.d.ts.map +0 -1
- package/dist/type/migratorDialect.js.map +0 -1
- package/dist/type/namingStrategy.d.ts.map +0 -1
- package/dist/type/namingStrategy.js.map +0 -1
- package/dist/type/querier.d.ts.map +0 -1
- package/dist/type/querier.js.map +0 -1
- package/dist/type/querierPool.d.ts.map +0 -1
- package/dist/type/querierPool.js.map +0 -1
- package/dist/type/query.d.ts.map +0 -1
- package/dist/type/query.js.map +0 -1
- package/dist/type/queryAggregate.d.ts.map +0 -1
- package/dist/type/queryAggregate.js.map +0 -1
- package/dist/type/queryRaw.d.ts.map +0 -1
- package/dist/type/queryRaw.js.map +0 -1
- package/dist/type/queryWhere.d.ts.map +0 -1
- package/dist/type/queryWhere.js.map +0 -1
- package/dist/type/universalQuerier.d.ts.map +0 -1
- package/dist/type/universalQuerier.js.map +0 -1
- package/dist/type/utility.d.ts.map +0 -1
- package/dist/type/utility.js.map +0 -1
- package/dist/type/vector.d.ts.map +0 -1
- package/dist/type/vector.js.map +0 -1
- package/dist/util/ansiSqlLiteral.d.ts +0 -23
- package/dist/util/ansiSqlLiteral.d.ts.map +0 -1
- package/dist/util/ansiSqlLiteral.js +0 -105
- package/dist/util/ansiSqlLiteral.js.map +0 -1
- package/dist/util/dialect.util.d.ts.map +0 -1
- package/dist/util/dialect.util.js.map +0 -1
- package/dist/util/field.util.d.ts.map +0 -1
- package/dist/util/field.util.js.map +0 -1
- package/dist/util/filters.util.d.ts.map +0 -1
- package/dist/util/filters.util.js.map +0 -1
- package/dist/util/hook.util.d.ts.map +0 -1
- package/dist/util/hook.util.js.map +0 -1
- package/dist/util/index.d.ts.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util/logger.d.ts.map +0 -1
- package/dist/util/logger.js.map +0 -1
- package/dist/util/object.util.d.ts.map +0 -1
- package/dist/util/object.util.js.map +0 -1
- package/dist/util/raw.d.ts.map +0 -1
- package/dist/util/raw.js.map +0 -1
- package/dist/util/relationQuery.util.d.ts.map +0 -1
- package/dist/util/relationQuery.util.js.map +0 -1
- package/dist/util/sql.util.d.ts.map +0 -1
- package/dist/util/sql.util.js.map +0 -1
- package/dist/util/string.util.d.ts.map +0 -1
- package/dist/util/string.util.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ObjectId } from 'mongodb';
|
|
2
2
|
import { AbstractDialect } from '../dialect/abstractDialect.js';
|
|
3
3
|
import { getMeta } from '../entity/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { QueryRaw } from '../type/queryRaw.js';
|
|
5
|
+
import { asSelectMap, buildQueryWhereAsMap, buildSortMap, fillOnFields, filterFieldKeys, getKeys, getRelationRequestSummary, hasKeys, isJsonUpdateOp, isOperatorObject, isVectorSearch, normalizeScalarFieldSelection, parseGroupMap, parseRelationAtKey, parseRelationSize, } from '../util/index.js';
|
|
5
6
|
/** Default {@link DialectFeatures} for MongoDB; shared by {@link MongoDialect} and its schema generator. */
|
|
6
7
|
export const mongoDialectFeatures = {
|
|
7
8
|
explicitJsonCast: false,
|
|
@@ -13,7 +14,7 @@ export const mongoDialectFeatures = {
|
|
|
13
14
|
renameColumn: false,
|
|
14
15
|
foreignKeyAlter: false,
|
|
15
16
|
columnComment: false,
|
|
16
|
-
|
|
17
|
+
inlineVectorIndex: false,
|
|
17
18
|
vectorSupportsLength: false,
|
|
18
19
|
supportsTimestamptz: false,
|
|
19
20
|
defaultStringAsText: false,
|
|
@@ -24,7 +25,13 @@ export class MongoDialect extends AbstractDialect {
|
|
|
24
25
|
// The MongoDB driver reports the exact `_id` of every inserted document (`insertedIds`).
|
|
25
26
|
insertIdSource = 'returning';
|
|
26
27
|
static ID_KEY = '_id';
|
|
28
|
+
/** Temporary lookup fields for relation conditions, dropped with `$unset` after the `$match`. */
|
|
29
|
+
static REL_TEMP_PREFIX = '__uql_rel_';
|
|
30
|
+
static REL_COUNT_KEY = 'n';
|
|
31
|
+
static REL_NESTED_KEY = '__uql_target';
|
|
27
32
|
static VECTOR_INDEX_TYPES = new Set(['vectorSearch', 'hnsw', 'ivfflat', 'vector']);
|
|
33
|
+
/** Atlas rejects a `$vectorSearch` asking for more candidates than this. */
|
|
34
|
+
static MAX_NUM_CANDIDATES = 10_000;
|
|
28
35
|
// Direct field aggregates → MongoDB accumulator. `$count` is handled separately (COUNT(*) vs
|
|
29
36
|
// COUNT(field) differ), so it is not listed here.
|
|
30
37
|
static AGGREGATE_OP_MAP = new Map([
|
|
@@ -33,14 +40,52 @@ export class MongoDialect extends AbstractDialect {
|
|
|
33
40
|
['$min', '$min'],
|
|
34
41
|
['$max', '$max'],
|
|
35
42
|
]);
|
|
43
|
+
/**
|
|
44
|
+
* MongoDB stores the primary key as `_id`; everything else resolves as usual. Projections, sorts,
|
|
45
|
+
* `$group` refs and `$where` keys all map through here, so no read path can address a property name
|
|
46
|
+
* the document does not use.
|
|
47
|
+
*/
|
|
48
|
+
columnOf(meta, key) {
|
|
49
|
+
if (key === MongoDialect.ID_KEY || key === meta.id) {
|
|
50
|
+
return MongoDialect.ID_KEY;
|
|
51
|
+
}
|
|
52
|
+
return super.columnOf(meta, key);
|
|
53
|
+
}
|
|
36
54
|
where(entity, where = {}, opts = {}) {
|
|
37
55
|
const meta = getMeta(entity);
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
// Filters are applied once, here at the scope entry point; recursion uses `renderFilter`.
|
|
57
|
+
return this.renderFilter(entity, this.scopedWhereMap(meta, where, opts));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A `$where` that may constrain relations, split into the `$lookup` stages it needs and the `$match`
|
|
61
|
+
* filter that consumes them. Each relation condition becomes one correlated lookup into a temporary
|
|
62
|
+
* field plus an ordinary condition on that field, so the caller's boolean structure survives intact
|
|
63
|
+
* (a relation inside `$or` still means what it says) and nothing depends on materializing ids.
|
|
64
|
+
* `unset` names the temporary fields, which the caller drops once the match is done.
|
|
65
|
+
*/
|
|
66
|
+
whereWithRelations(entity, where = {}, opts = {}) {
|
|
67
|
+
const meta = getMeta(entity);
|
|
68
|
+
const lookups = { stages: [], temps: [] };
|
|
69
|
+
const filter = this.renderFilter(entity, this.scopedWhereMap(meta, where, opts), opts, lookups);
|
|
70
|
+
return { stages: lookups.stages, filter, unset: lookups.temps };
|
|
71
|
+
}
|
|
72
|
+
/** Whether a `$where` constrains any relation, and so needs the aggregation path rather than a cursor. */
|
|
73
|
+
constrainsRelations(entity, where) {
|
|
74
|
+
if (!where) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const meta = getMeta(entity);
|
|
78
|
+
const whereMap = buildQueryWhereAsMap(meta, where);
|
|
79
|
+
return Object.entries(whereMap).some(([key, val]) => key === '$and' || key === '$or'
|
|
80
|
+
? val.some((it) => this.constrainsRelations(entity, it))
|
|
81
|
+
: Boolean(meta.relations[key]));
|
|
41
82
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Renders a `$where` tree without applying entity filters (used for same-scope `$and`/`$or`
|
|
85
|
+
* recursion). Relation keys need `$lookup` stages, so they are only accepted when `lookups` is
|
|
86
|
+
* given - a plain `find`/`updateMany` filter has nowhere to put them.
|
|
87
|
+
*/
|
|
88
|
+
renderFilter(entity, where = {}, opts, lookups) {
|
|
44
89
|
const meta = getMeta(entity);
|
|
45
90
|
const whereMap = buildQueryWhereAsMap(meta, where);
|
|
46
91
|
const filter = {};
|
|
@@ -48,17 +93,32 @@ export class MongoDialect extends AbstractDialect {
|
|
|
48
93
|
let key = rawKey;
|
|
49
94
|
let val = rawVal;
|
|
50
95
|
if (key === '$and' || key === '$or') {
|
|
51
|
-
filter[key] = val.map((filterIt) =>
|
|
96
|
+
filter[key] = val.map((filterIt) => {
|
|
97
|
+
// A `QueryRaw` here would recurse forever: `buildQueryWhereAsMap` re-wraps it as
|
|
98
|
+
// `{ $and: [raw] }`, which lands back on this branch.
|
|
99
|
+
this.assertNoRaw(filterIt);
|
|
100
|
+
return this.renderFilter(entity, filterIt, opts, lookups);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else if (key === '$text') {
|
|
104
|
+
// MongoDB's text index declares which fields it covers, so `$fields` cannot narrow the search
|
|
105
|
+
// the way it does elsewhere - the same shape as `$distance` being index-defined here.
|
|
106
|
+
filter['$text'] = { $search: val.$value };
|
|
107
|
+
}
|
|
108
|
+
else if (meta.relations[key]) {
|
|
109
|
+
this.assertNoRaw(val);
|
|
110
|
+
if (!lookups) {
|
|
111
|
+
throw new TypeError(`filtering by relation '${key}' is not supported here on MongoDB`);
|
|
112
|
+
}
|
|
113
|
+
Object.assign(filter, this.appendRelationLookup(meta, key, val, opts, lookups));
|
|
52
114
|
}
|
|
53
115
|
else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
116
|
+
this.assertNoRaw(val);
|
|
117
|
+
this.assertKnownPathRoot(meta, key);
|
|
118
|
+
key = this.pathOf(meta, key);
|
|
119
|
+
if (key === MongoDialect.ID_KEY) {
|
|
57
120
|
val = this.getIdValue(val);
|
|
58
121
|
}
|
|
59
|
-
else if (field) {
|
|
60
|
-
key = this.resolveColumnName(key, field);
|
|
61
|
-
}
|
|
62
122
|
if (isOperatorObject(val)) {
|
|
63
123
|
val = this.transformOperators(val);
|
|
64
124
|
}
|
|
@@ -70,6 +130,115 @@ export class MongoDialect extends AbstractDialect {
|
|
|
70
130
|
}
|
|
71
131
|
return filter;
|
|
72
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Emits the correlated `$lookup` for one relation condition and returns the condition that tests its
|
|
135
|
+
* result: presence of a row for a plain relation filter, a comparison against the row count for
|
|
136
|
+
* `$size`. The target's (and, for ManyToMany, the junction's) own filters scope the lookup, so a
|
|
137
|
+
* relation subquery can no more read out-of-scope rows than a direct query on the target can.
|
|
138
|
+
*/
|
|
139
|
+
appendRelationLookup(meta, relKey, val, opts, lookups) {
|
|
140
|
+
const relOpts = meta.relations[relKey];
|
|
141
|
+
const relEntity = relOpts.entity();
|
|
142
|
+
const relMeta = getMeta(relEntity);
|
|
143
|
+
const temp = `${MongoDialect.REL_TEMP_PREFIX}${lookups.temps.length}`;
|
|
144
|
+
const sizeVal = parseRelationSize(val);
|
|
145
|
+
// `$count` for a size test, `$limit: 1` for existence: neither returns the matched documents.
|
|
146
|
+
const tail = sizeVal === undefined ? [{ $limit: 1 }] : [{ $count: MongoDialect.REL_COUNT_KEY }];
|
|
147
|
+
// Scope first, render once - merging the target's filters into an already-rendered filter would
|
|
148
|
+
// leave their own keys unmapped. The caller's filter bypass is deliberately *not* passed down:
|
|
149
|
+
// `withDeleted()` or `hardDelete` on the parent must not un-hide trashed rows of the target, the
|
|
150
|
+
// same rule the SQL dialects' relation subqueries follow.
|
|
151
|
+
const targetCondition = (sizeVal === undefined ? val : {});
|
|
152
|
+
const targetScope = this.renderFilter(relEntity, this.scopedWhereMap(relMeta, targetCondition), opts);
|
|
153
|
+
lookups.temps.push(temp);
|
|
154
|
+
lookups.stages.push(relOpts.cardinality === 'mm' && relOpts.through
|
|
155
|
+
? this.junctionLookup(meta, relOpts, relMeta, relEntity, targetScope, temp, tail, opts)
|
|
156
|
+
: {
|
|
157
|
+
$lookup: {
|
|
158
|
+
from: this.resolveTableName(relEntity, relMeta),
|
|
159
|
+
...this.joinKeys(meta, relMeta, relOpts),
|
|
160
|
+
pipeline: [...(hasKeys(targetScope) ? [{ $match: targetScope }] : []), ...tail],
|
|
161
|
+
as: temp,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
return sizeVal === undefined
|
|
165
|
+
? { [`${temp}.0`]: { $exists: true } }
|
|
166
|
+
: { $expr: this.compareRelationCount(temp, sizeVal) };
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* ManyToMany counts/tests junction rows, so the target is reached from inside the junction's own
|
|
170
|
+
* lookup - the junction's filters apply too, since a soft-deleted link is not a link.
|
|
171
|
+
*/
|
|
172
|
+
junctionLookup(meta, relOpts, relMeta, relEntity, targetScope, temp, tail, opts) {
|
|
173
|
+
const throughEntity = relOpts.through();
|
|
174
|
+
const throughMeta = getMeta(throughEntity);
|
|
175
|
+
const junctionScope = this.renderFilter(throughEntity, this.scopedWhereMap(throughMeta, {}), opts);
|
|
176
|
+
const nested = MongoDialect.REL_NESTED_KEY;
|
|
177
|
+
return {
|
|
178
|
+
$lookup: {
|
|
179
|
+
from: this.resolveTableName(throughEntity, throughMeta),
|
|
180
|
+
localField: MongoDialect.ID_KEY,
|
|
181
|
+
foreignField: this.columnOf(throughMeta, relOpts.references[0].local),
|
|
182
|
+
pipeline: [
|
|
183
|
+
...(hasKeys(junctionScope) ? [{ $match: junctionScope }] : []),
|
|
184
|
+
{
|
|
185
|
+
$lookup: {
|
|
186
|
+
from: this.resolveTableName(relEntity, relMeta),
|
|
187
|
+
localField: this.columnOf(throughMeta, relOpts.references[1].local),
|
|
188
|
+
foreignField: MongoDialect.ID_KEY,
|
|
189
|
+
pipeline: [...(hasKeys(targetScope) ? [{ $match: targetScope }] : []), { $limit: 1 }],
|
|
190
|
+
as: nested,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{ $match: { [`${nested}.0`]: { $exists: true } } },
|
|
194
|
+
...tail,
|
|
195
|
+
],
|
|
196
|
+
as: temp,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Compares the looked-up row count, which is `[{ n: <count> }]` or `[]` when nothing matched - hence
|
|
202
|
+
* the `$ifNull` fallback to 0, so `{ $size: 0 }` matches parents with no related row at all.
|
|
203
|
+
*/
|
|
204
|
+
compareRelationCount(temp, sizeVal) {
|
|
205
|
+
const count = { $ifNull: [{ $arrayElemAt: [`$${temp}.${MongoDialect.REL_COUNT_KEY}`, 0] }, 0] };
|
|
206
|
+
if (typeof sizeVal === 'number') {
|
|
207
|
+
return { $eq: [count, sizeVal] };
|
|
208
|
+
}
|
|
209
|
+
const comparisons = Object.entries(sizeVal)
|
|
210
|
+
.filter(([, bound]) => bound !== undefined)
|
|
211
|
+
.flatMap(([op, bound]) => op === '$between'
|
|
212
|
+
? [{ $gte: [count, bound[0]] }, { $lte: [count, bound[1]] }]
|
|
213
|
+
: [{ [op]: [count, bound] }]);
|
|
214
|
+
if (!comparisons.length) {
|
|
215
|
+
throw new TypeError('$size on a relation needs at least one comparison');
|
|
216
|
+
}
|
|
217
|
+
return comparisons.length === 1 ? comparisons[0] : { $and: comparisons };
|
|
218
|
+
}
|
|
219
|
+
/** Whether a query subtracts `key` from the projection, via `$exclude` or a negative `$select`. */
|
|
220
|
+
subtractsKey(key, select, exclude) {
|
|
221
|
+
const at = (map) => map?.[key];
|
|
222
|
+
return at(exclude) === true || at(select) === false;
|
|
223
|
+
}
|
|
224
|
+
/** `raw()` renders SQL, so it has no MongoDB equivalent - say so instead of emitting `{}`. */
|
|
225
|
+
assertNoRaw(value) {
|
|
226
|
+
if (value instanceof QueryRaw) {
|
|
227
|
+
throw new TypeError('raw() in $where is not supported on MongoDB');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* A dotted key addresses an embedded path, whose root must still be a declared field - otherwise it
|
|
232
|
+
* is a typo (or an injected key) that would silently match nothing, the same guard the SQL dialects
|
|
233
|
+
* apply to JSON paths.
|
|
234
|
+
*/
|
|
235
|
+
assertKnownPathRoot(meta, key) {
|
|
236
|
+
const root = key.includes('.') ? key.slice(0, key.indexOf('.')) : key;
|
|
237
|
+
if (root === MongoDialect.ID_KEY || root === meta.id || meta.fields[root]) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
throw new TypeError(`path ${key} does not exist in ${meta.name ?? ''}`);
|
|
241
|
+
}
|
|
73
242
|
mapTableNameRow(row) {
|
|
74
243
|
return row.table_name;
|
|
75
244
|
}
|
|
@@ -168,87 +337,145 @@ export class MongoDialect extends AbstractDialect {
|
|
|
168
337
|
if (Array.isArray(select)) {
|
|
169
338
|
throw new TypeError('raw $select is not supported on MongoDB');
|
|
170
339
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
340
|
+
const selectMap = asSelectMap(select);
|
|
341
|
+
// Projected by column, not by field key; `normalizeId` maps them back on the way out.
|
|
342
|
+
const projection = normalizeScalarFieldSelection(meta, selectMap, exclude).reduce((acc, key) => {
|
|
343
|
+
acc[this.columnOf(meta, key)] = 1;
|
|
174
344
|
return acc;
|
|
175
345
|
}, {});
|
|
346
|
+
// MongoDB returns `_id` unless it is explicitly excluded, so subtracting the primary key needs
|
|
347
|
+
// `_id: 0` - the one inclusion/exclusion mix MongoDB allows - or `$exclude: { id: true }` would
|
|
348
|
+
// have no effect at all.
|
|
349
|
+
if (this.subtractsKey(meta.id, selectMap, exclude)) {
|
|
350
|
+
projection[MongoDialect.ID_KEY] = 0;
|
|
351
|
+
}
|
|
352
|
+
return projection;
|
|
176
353
|
}
|
|
177
354
|
sort(entity, sort) {
|
|
178
|
-
const
|
|
355
|
+
const meta = getMeta(entity);
|
|
356
|
+
return this.sortBy(sort, (key) => {
|
|
357
|
+
if (meta.relations[key]) {
|
|
358
|
+
throw new TypeError(`sorting by relation '${key}' is not supported on MongoDB`);
|
|
359
|
+
}
|
|
360
|
+
return this.pathOf(meta, key);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Aggregate results are keyed by `$group`/`$agg` alias rather than by column, so an aggregate
|
|
365
|
+
* `$sort` addresses those aliases as-is - the same reason the SQL dialects sort by alias there.
|
|
366
|
+
*/
|
|
367
|
+
aliasSort(sort) {
|
|
368
|
+
return this.sortBy(sort, (alias) => alias);
|
|
369
|
+
}
|
|
370
|
+
/** Shared direction normalization; `mapKey` decides whether keys are columns or aggregate aliases. */
|
|
371
|
+
sortBy(sort, mapKey) {
|
|
179
372
|
const normalized = {};
|
|
180
|
-
for (const [key, dir] of Object.entries(
|
|
181
|
-
normalized[key] = dir === 'desc' || dir === -1 ? -1 : 1;
|
|
373
|
+
for (const [key, dir] of Object.entries(buildSortMap(sort))) {
|
|
374
|
+
normalized[mapKey(key)] = dir === 'desc' || dir === -1 ? -1 : 1;
|
|
182
375
|
}
|
|
183
376
|
return normalized;
|
|
184
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* {@link columnOf} for a possibly dotted key: only the root is a field key, the rest addresses an
|
|
380
|
+
* embedded path (`kind.city` -> `<kind's column>.city`).
|
|
381
|
+
*/
|
|
382
|
+
pathOf(meta, key) {
|
|
383
|
+
const dot = key.indexOf('.');
|
|
384
|
+
if (dot < 0) {
|
|
385
|
+
return this.columnOf(meta, key);
|
|
386
|
+
}
|
|
387
|
+
return this.columnOf(meta, key.slice(0, dot)) + key.slice(dot);
|
|
388
|
+
}
|
|
185
389
|
aggregationPipeline(entity, q, relationSummary, opts) {
|
|
186
|
-
const
|
|
187
|
-
const where = this.where(entity, q.$where, opts);
|
|
390
|
+
const { stages, filter, unset } = this.whereWithRelations(entity, q.$where, opts);
|
|
188
391
|
const sort = this.sort(entity, q.$sort);
|
|
189
|
-
const
|
|
190
|
-
if (hasKeys(
|
|
191
|
-
|
|
392
|
+
const match = {};
|
|
393
|
+
if (hasKeys(filter)) {
|
|
394
|
+
match.$match = filter;
|
|
192
395
|
}
|
|
193
396
|
if (hasKeys(sort)) {
|
|
194
|
-
|
|
195
|
-
}
|
|
397
|
+
match.$sort = sort;
|
|
398
|
+
}
|
|
399
|
+
// Lookups that a relation condition needs come first, then the match that reads them, then the
|
|
400
|
+
// temporary fields are dropped so they never reach the caller.
|
|
401
|
+
const pipeline = [...stages];
|
|
402
|
+
if (hasKeys(match)) {
|
|
403
|
+
pipeline.push(match);
|
|
404
|
+
}
|
|
405
|
+
if (unset.length) {
|
|
406
|
+
pipeline.push({ $unset: unset });
|
|
407
|
+
}
|
|
408
|
+
const relStages = this.relationStages(entity, q, relationSummary, opts);
|
|
409
|
+
const pager = [
|
|
410
|
+
...(q.$skip === undefined ? [] : [{ $skip: q.$skip }]),
|
|
411
|
+
...(q.$limit === undefined ? [] : [{ $limit: q.$limit }]),
|
|
412
|
+
];
|
|
413
|
+
// A `$required` relation drops parents when it unwinds, so paging has to come after it - as it
|
|
414
|
+
// does after an INNER JOIN. Otherwise paging first is equivalent and spares the lookups.
|
|
415
|
+
const dropsParents = relStages.some((stage) => stage.$unwind?.preserveNullAndEmptyArrays === false);
|
|
416
|
+
pipeline.push(...(dropsParents ? [...relStages, ...pager] : [...pager, ...relStages]));
|
|
417
|
+
return pipeline;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* `$lookup`/`$unwind` stages for the joinable relations a query populates. Shared by the plain
|
|
421
|
+
* aggregation pipeline and the `$vectorSearch` one, so relations load the same way in both.
|
|
422
|
+
*/
|
|
423
|
+
relationStages(entity, q, relationSummary, opts) {
|
|
424
|
+
const meta = getMeta(entity);
|
|
196
425
|
const pipeline = [];
|
|
197
|
-
if (hasKeys(firstPipelineEntry)) {
|
|
198
|
-
pipeline.push(firstPipelineEntry);
|
|
199
|
-
}
|
|
200
426
|
const relKeys = (relationSummary ?? getRelationRequestSummary(meta, q.$populate)).joinableKeys;
|
|
201
427
|
for (const relKey of relKeys) {
|
|
202
428
|
const relOpts = meta.relations[relKey];
|
|
203
429
|
if (!relOpts)
|
|
204
430
|
continue;
|
|
205
431
|
if (relOpts.cardinality === '1m' || relOpts.cardinality === 'mm') {
|
|
206
|
-
// '1m' and 'mm'
|
|
432
|
+
// '1m' and 'mm' are resolved in a higher layer: they need a second query each.
|
|
207
433
|
continue;
|
|
208
434
|
}
|
|
209
435
|
const relEntity = relOpts.entity();
|
|
210
436
|
const relMeta = getMeta(relEntity);
|
|
437
|
+
const { query: relQuery, required } = parseRelationAtKey(relKey, q.$populate);
|
|
211
438
|
// Unconditional, not gated by an explicit relation-level `$where`: the related entity's own
|
|
212
439
|
// filters (in particular `security: true` ones) must apply even to a bare
|
|
213
440
|
// `$populate: { rel: true }`, exactly like the SQL dialects' JOIN ON-clause filters.
|
|
214
|
-
const relationFilter = this.where(relEntity, {}, opts);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
as: relKey,
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
const foreignField = relMeta.fields[relOpts.references[0].foreign];
|
|
231
|
-
const foreignFieldName = this.resolveColumnName(relOpts.references[0].foreign, foreignField);
|
|
232
|
-
const referenceSort = this.sort(relEntity, q.$sort);
|
|
233
|
-
const _id = MongoDialect.ID_KEY;
|
|
234
|
-
const referencePipelineEntry = {
|
|
235
|
-
$match: { [foreignFieldName]: where[_id], ...relationFilter },
|
|
236
|
-
};
|
|
237
|
-
if (hasKeys(referenceSort)) {
|
|
238
|
-
referencePipelineEntry.$sort = referenceSort;
|
|
239
|
-
}
|
|
240
|
-
pipeline.push({
|
|
241
|
-
$lookup: {
|
|
242
|
-
from: this.resolveTableName(relEntity, relMeta),
|
|
243
|
-
pipeline: [referencePipelineEntry],
|
|
244
|
-
as: relKey,
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
pipeline.push({ $unwind: { path: `$${relKey}`, preserveNullAndEmptyArrays: true } });
|
|
441
|
+
const relationFilter = this.where(relEntity, relQuery.$where ?? {}, opts);
|
|
442
|
+
pipeline.push({
|
|
443
|
+
$lookup: {
|
|
444
|
+
from: this.resolveTableName(relEntity, relMeta),
|
|
445
|
+
...this.joinKeys(meta, relMeta, relOpts),
|
|
446
|
+
...(hasKeys(relationFilter) ? { pipeline: [{ $match: relationFilter }] } : {}),
|
|
447
|
+
as: relKey,
|
|
448
|
+
},
|
|
449
|
+
});
|
|
450
|
+
// `$required` drops parents with no match, the aggregation equivalent of an INNER JOIN.
|
|
451
|
+
pipeline.push({ $unwind: { path: `$${relKey}`, preserveNullAndEmptyArrays: !required } });
|
|
249
452
|
}
|
|
250
453
|
return pipeline;
|
|
251
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* The correlated join for a single-valued or one-to-many relation. MongoDB runs a lookup's `pipeline`
|
|
457
|
+
* after its own localField/foreignField match, so the target's filters layer on top of the join
|
|
458
|
+
* condition with no `let`/`$expr` rewrite: m1 joins the parent's FK to the target's `_id`, every other
|
|
459
|
+
* direction joins the parent's `_id` to the target's FK.
|
|
460
|
+
*/
|
|
461
|
+
joinKeys(meta, relMeta, relOpts) {
|
|
462
|
+
return relOpts.cardinality === 'm1'
|
|
463
|
+
? { localField: this.columnOf(meta, relOpts.references[0].local), foreignField: MongoDialect.ID_KEY }
|
|
464
|
+
: { localField: MongoDialect.ID_KEY, foreignField: this.columnOf(relMeta, relOpts.references[0].foreign) };
|
|
465
|
+
}
|
|
466
|
+
/** `[column, key]` for the fields whose stored name differs from their property name, memoized per entity. */
|
|
467
|
+
renamedColumns(meta) {
|
|
468
|
+
let renamed = this.#renamedColumns.get(meta);
|
|
469
|
+
if (!renamed) {
|
|
470
|
+
renamed = getKeys(meta.fields)
|
|
471
|
+
.map((key) => [this.columnOf(meta, key), key])
|
|
472
|
+
.filter(([column, key]) => column !== key);
|
|
473
|
+
this.#renamedColumns.set(meta, renamed);
|
|
474
|
+
}
|
|
475
|
+
return renamed;
|
|
476
|
+
}
|
|
477
|
+
// Keyed by the meta object itself; entity metadata is immutable once defined.
|
|
478
|
+
#renamedColumns = new WeakMap();
|
|
252
479
|
normalizeIds(meta, docs) {
|
|
253
480
|
return docs?.map((doc) => this.normalizeId(meta, doc));
|
|
254
481
|
}
|
|
@@ -264,12 +491,12 @@ export class MongoDialect extends AbstractDialect {
|
|
|
264
491
|
delete res[_id];
|
|
265
492
|
}
|
|
266
493
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
res[key] = res[
|
|
272
|
-
delete res[
|
|
494
|
+
// Only the renamed fields need touching, and which those are is a property of the entity, not of
|
|
495
|
+
// the document - so it is derived once instead of for every row of a result set.
|
|
496
|
+
for (const [column, key] of this.renamedColumns(meta)) {
|
|
497
|
+
if (res[column] !== undefined) {
|
|
498
|
+
res[key] = res[column];
|
|
499
|
+
delete res[column];
|
|
273
500
|
}
|
|
274
501
|
}
|
|
275
502
|
const relKeys = getKeys(meta.relations).filter((key) => res[key]);
|
|
@@ -398,7 +625,7 @@ export class MongoDialect extends AbstractDialect {
|
|
|
398
625
|
}
|
|
399
626
|
}
|
|
400
627
|
// $group stage
|
|
401
|
-
const { groupId, groupAccumulators, distinctReducers } = this.buildGroupSpec(parseGroupMap(q.$group, q.$agg));
|
|
628
|
+
const { groupId, groupAccumulators, distinctReducers } = this.buildGroupSpec(getMeta(entity), parseGroupMap(q.$group, q.$agg));
|
|
402
629
|
pipeline.push({ $group: { _id: hasKeys(groupId) ? groupId : null, ...groupAccumulators } });
|
|
403
630
|
// Project stage - rename _id fields back to their original names, and reduce collected distinct
|
|
404
631
|
// sets. Needed whenever there are group keys OR any distinct alias.
|
|
@@ -420,9 +647,9 @@ export class MongoDialect extends AbstractDialect {
|
|
|
420
647
|
pipeline.push({ $match: havingFilter });
|
|
421
648
|
}
|
|
422
649
|
}
|
|
423
|
-
// $sort stage
|
|
650
|
+
// $sort stage - by alias, since $group/$project already renamed everything
|
|
424
651
|
if (q.$sort) {
|
|
425
|
-
const sort = this.
|
|
652
|
+
const sort = this.aliasSort(q.$sort);
|
|
426
653
|
if (hasKeys(sort)) {
|
|
427
654
|
pipeline.push({ $sort: sort });
|
|
428
655
|
}
|
|
@@ -441,7 +668,7 @@ export class MongoDialect extends AbstractDialect {
|
|
|
441
668
|
* `distinctReducers` maps each DISTINCT alias (collected via `$addToSet`) to the `$project`
|
|
442
669
|
* operator that reduces its set: `$size` for `$count`, `$sum`/`$avg` for the numeric ops.
|
|
443
670
|
*/
|
|
444
|
-
buildGroupSpec(groupEntries) {
|
|
671
|
+
buildGroupSpec(meta, groupEntries) {
|
|
445
672
|
if (!groupEntries.length) {
|
|
446
673
|
throw new TypeError('aggregate requires at least one $group column or $agg function');
|
|
447
674
|
}
|
|
@@ -449,25 +676,27 @@ export class MongoDialect extends AbstractDialect {
|
|
|
449
676
|
const groupAccumulators = {};
|
|
450
677
|
const distinctReducers = new Map();
|
|
451
678
|
for (const entry of groupEntries) {
|
|
679
|
+
// Aliases stay as the caller wrote them ($project maps them back); the *refs* address columns.
|
|
680
|
+
const ref = entry.kind === 'key' ? `$${this.columnOf(meta, entry.alias)}` : `$${this.columnOf(meta, entry.fieldRef)}`;
|
|
452
681
|
if (entry.kind === 'key') {
|
|
453
|
-
groupId[entry.alias] =
|
|
682
|
+
groupId[entry.alias] = ref;
|
|
454
683
|
}
|
|
455
684
|
else if (entry.distinct) {
|
|
456
685
|
// Collect the set now; reduce it in $project: `$size` counts it, `$sum`/`$avg` reduce the array.
|
|
457
|
-
groupAccumulators[entry.alias] = { $addToSet:
|
|
686
|
+
groupAccumulators[entry.alias] = { $addToSet: ref };
|
|
458
687
|
distinctReducers.set(entry.alias, entry.op === '$count' ? '$size' : entry.op);
|
|
459
688
|
}
|
|
460
689
|
else if (entry.op === '$count') {
|
|
461
690
|
// COUNT(*) counts every row; COUNT(field) counts non-null values, matching SQL.
|
|
462
691
|
groupAccumulators[entry.alias] =
|
|
463
|
-
entry.fieldRef === '*' ? { $sum: 1 } : { $sum: { $cond: [{ $ne: [
|
|
692
|
+
entry.fieldRef === '*' ? { $sum: 1 } : { $sum: { $cond: [{ $ne: [ref, null] }, 1, 0] } };
|
|
464
693
|
}
|
|
465
694
|
else {
|
|
466
695
|
const mongoOp = MongoDialect.AGGREGATE_OP_MAP.get(entry.op);
|
|
467
696
|
if (!mongoOp) {
|
|
468
697
|
throw TypeError(`unsupported aggregate operator: ${entry.op}`);
|
|
469
698
|
}
|
|
470
|
-
groupAccumulators[entry.alias] = { [mongoOp]:
|
|
699
|
+
groupAccumulators[entry.alias] = { [mongoOp]: ref };
|
|
471
700
|
}
|
|
472
701
|
}
|
|
473
702
|
return { groupId, groupAccumulators, distinctReducers };
|
|
@@ -522,13 +751,17 @@ export class MongoDialect extends AbstractDialect {
|
|
|
522
751
|
}
|
|
523
752
|
const colName = this.resolveColumnName(key, field);
|
|
524
753
|
// Resolve index name from @Index metadata, or fall back to convention
|
|
525
|
-
const indexMeta = meta.indexes?.find((idx) => idx.columns.
|
|
754
|
+
const indexMeta = meta.indexes?.find((idx) => idx.columns.some((entry) => entry.column === key) && MongoDialect.VECTOR_INDEX_TYPES.has(idx.type));
|
|
526
755
|
const indexName = indexMeta?.name ?? `${colName}_index`;
|
|
756
|
+
if (!limit) {
|
|
757
|
+
throw new TypeError(`$vectorSearch requires $limit (vector sort on '${key}' of '${meta.name}')`);
|
|
758
|
+
}
|
|
527
759
|
const stage = {
|
|
528
760
|
index: indexName,
|
|
529
761
|
path: colName,
|
|
530
762
|
queryVector: [...search.$vector],
|
|
531
|
-
numCandidates
|
|
763
|
+
// Atlas caps `numCandidates` at 10000 and wants roughly 10x the limit below that.
|
|
764
|
+
numCandidates: Math.min(limit * 10, MongoDialect.MAX_NUM_CANDIDATES),
|
|
532
765
|
limit,
|
|
533
766
|
};
|
|
534
767
|
// Pre-filter: merge $where into $vectorSearch.filter
|
|
@@ -541,4 +774,3 @@ export class MongoDialect extends AbstractDialect {
|
|
|
541
774
|
return { $vectorSearch: stage };
|
|
542
775
|
}
|
|
543
776
|
}
|
|
544
|
-
//# sourceMappingURL=mongoDialect.js.map
|
|
@@ -23,6 +23,11 @@ export declare class MongodbQuerier extends AbstractQuerier {
|
|
|
23
23
|
private buildVectorPipeline;
|
|
24
24
|
protected internalAggregate<E extends Document, G extends QueryGroupMap<E>, A extends QueryAggMap<E>>(entity: Type<E>, q: QueryAggregate<E, G, A>, opts?: QueryOptions): Promise<QueryAggregateResult<E, G, A>[]>;
|
|
25
25
|
protected internalCount<E extends Document>(entity: Type<E>, qm?: QuerySearch<E>, opts?: QueryOptions): Promise<number>;
|
|
26
|
+
/**
|
|
27
|
+
* The `_id`s a search matches. Writes need this whenever the `$where` constrains a relation, since a
|
|
28
|
+
* MongoDB `updateMany`/`deleteMany` filter cannot host a `$lookup` - reads never pay this cost.
|
|
29
|
+
*/
|
|
30
|
+
private matchedIds;
|
|
26
31
|
internalInsertMany<E extends Document>(entity: Type<E>, payloads: E[]): Promise<IdValue<E>[]>;
|
|
27
32
|
internalUpdateMany<E extends Document>(entity: Type<E>, qm: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryOptions): Promise<number>;
|
|
28
33
|
private buildConflictFilter;
|
|
@@ -49,4 +54,3 @@ export declare class MongodbQuerier extends AbstractQuerier {
|
|
|
49
54
|
rollbackTransaction(): Promise<void>;
|
|
50
55
|
internalRelease(): Promise<void>;
|
|
51
56
|
}
|
|
52
|
-
//# sourceMappingURL=mongodbQuerier.d.ts.map
|