uql-orm 0.20.2 → 0.21.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 +45 -109
- 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 +0 -1
- package/dist/bunSql/bunSqlCockroachDialect.js +0 -1
- package/dist/bunSql/bunSqlPostgresDialect.d.ts +0 -1
- package/dist/bunSql/bunSqlPostgresDialect.js +0 -1
- 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 +0 -1
- package/dist/cockroachdb/cockroachDialect.js +0 -1
- 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 +0 -1
- package/dist/d1/d1Querier.js +0 -1
- package/dist/d1/d1QuerierPool.d.ts +0 -1
- package/dist/d1/d1QuerierPool.js +0 -1
- package/dist/d1/d1SqliteDialect.d.ts +0 -1
- package/dist/d1/d1SqliteDialect.js +0 -1
- package/dist/d1/index.d.ts +0 -1
- package/dist/d1/index.js +0 -1
- package/dist/dialect/abstractDialect.d.ts +13 -2
- package/dist/dialect/abstractDialect.js +17 -1
- package/dist/dialect/abstractSqlDialect.d.ts +27 -15
- package/dist/dialect/abstractSqlDialect.js +121 -139
- package/dist/dialect/index.d.ts +0 -1
- package/dist/dialect/index.js +0 -1
- 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 +0 -1
- package/dist/dialect/mysqlLikeSqlDialect.js +2 -4
- package/dist/dialect/pgLikeSqlDialect.d.ts +3 -3
- package/dist/dialect/pgLikeSqlDialect.js +7 -18
- package/dist/dialect/queryContext.d.ts +0 -1
- package/dist/dialect/queryContext.js +0 -1
- package/dist/dialect/vectorCast.d.ts +11 -0
- package/dist/dialect/vectorCast.js +13 -0
- package/dist/dialect/vectorSqlDialect.d.ts +1 -2
- package/dist/dialect/vectorSqlDialect.js +1 -2
- 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 +0 -1
- 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 +0 -2
- package/dist/entity/metadata/definition.js +6 -3
- 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 +0 -1
- package/dist/libsql/libsqlDialect.js +0 -1
- package/dist/libsql/libsqlQuerier.d.ts +0 -1
- package/dist/libsql/libsqlQuerier.js +9 -2
- package/dist/libsql/libsqlQuerierPool.d.ts +0 -1
- package/dist/libsql/libsqlQuerierPool.js +0 -1
- package/dist/maria/index.d.ts +0 -1
- package/dist/maria/index.js +0 -1
- package/dist/maria/mariaDialect.d.ts +0 -1
- package/dist/maria/mariaDialect.js +0 -1
- 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 +0 -1
- package/dist/migrate/builder/migrationBuilder.js +0 -1
- package/dist/migrate/builder/splitSqlStatements.d.ts +0 -1
- package/dist/migrate/builder/splitSqlStatements.js +0 -1
- package/dist/migrate/builder/tableBuilder.d.ts +0 -1
- package/dist/migrate/builder/tableBuilder.js +0 -1
- package/dist/migrate/builder/types.d.ts +0 -1
- 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 +0 -1
- package/dist/migrate/cli.js +0 -1
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -1
- package/dist/migrate/codegen/entityCodeGenerator.js +0 -1
- package/dist/migrate/codegen/entityMerger.d.ts +0 -1
- package/dist/migrate/codegen/entityMerger.js +0 -1
- package/dist/migrate/codegen/index.d.ts +0 -1
- package/dist/migrate/codegen/index.js +0 -1
- package/dist/migrate/codegen/migrationCodeGenerator.d.ts +0 -1
- package/dist/migrate/codegen/migrationCodeGenerator.js +0 -1
- 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/index.d.ts +0 -1
- package/dist/migrate/generator/index.js +0 -1
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +0 -1
- package/dist/migrate/generator/mongoSchemaGenerator.js +0 -1
- package/dist/migrate/index.d.ts +0 -1
- package/dist/migrate/index.js +0 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +0 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +0 -1
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -1
- package/dist/migrate/introspection/baseSqlIntrospector.js +0 -1
- 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 +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.js +0 -1
- package/dist/migrate/introspection/postgresIntrospector.d.ts +0 -1
- package/dist/migrate/introspection/postgresIntrospector.js +0 -1
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +0 -1
- package/dist/migrate/introspection/sqliteIntrospector.js +0 -1
- package/dist/migrate/migrator.d.ts +0 -1
- package/dist/migrate/migrator.js +0 -1
- package/dist/migrate/schemaGenerator.d.ts +0 -1
- package/dist/migrate/schemaGenerator.js +0 -1
- package/dist/migrate/schemaGeneratorAsync.d.ts +0 -1
- package/dist/migrate/schemaGeneratorAsync.js +0 -1
- package/dist/migrate/storage/databaseStorage.d.ts +0 -1
- package/dist/migrate/storage/databaseStorage.js +0 -1
- 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/migrate/sync/index.d.ts +0 -1
- package/dist/migrate/sync/index.js +0 -1
- package/dist/migrate/sync/schemaSync.d.ts +0 -1
- package/dist/migrate/sync/schemaSync.js +0 -1
- package/dist/mongo/index.d.ts +0 -1
- package/dist/mongo/index.js +0 -1
- package/dist/mongo/mongoDialect.d.ts +91 -5
- package/dist/mongo/mongoDialect.js +301 -80
- 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 +0 -1
- package/dist/mysql/mysqlDialect.js +0 -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 +0 -11
- package/dist/schema/canonicalType.js +0 -13
- package/dist/schema/index.d.ts +0 -1
- 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 +0 -1
- package/dist/schema/schemaASTBuilder.js +0 -1
- package/dist/schema/schemaASTDiffer.d.ts +0 -1
- package/dist/schema/schemaASTDiffer.js +0 -1
- package/dist/schema/types.d.ts +0 -1
- package/dist/schema/types.js +0 -1
- package/dist/sqlite/abstractSqliteQuerier.d.ts +0 -1
- package/dist/sqlite/abstractSqliteQuerier.js +0 -1
- package/dist/sqlite/betterSqlite3Dialect.d.ts +0 -1
- package/dist/sqlite/betterSqlite3Dialect.js +0 -1
- package/dist/sqlite/index.d.ts +0 -1
- package/dist/sqlite/index.js +0 -1
- package/dist/sqlite/sqliteDialect.d.ts +0 -1
- package/dist/sqlite/sqliteDialect.js +0 -1
- package/dist/sqlite/sqliteQuerier.d.ts +0 -1
- package/dist/sqlite/sqliteQuerier.js +0 -1
- package/dist/sqlite/sqliteQuerierPool.d.ts +0 -1
- package/dist/sqlite/sqliteQuerierPool.js +0 -1
- package/dist/type/config.d.ts +0 -1
- package/dist/type/config.js +0 -1
- package/dist/type/dialect.d.ts +0 -1
- package/dist/type/dialect.js +0 -1
- package/dist/type/entity.d.ts +0 -1
- 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 +0 -1
- 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 +0 -1
- 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 +0 -1
- package/dist/util/index.js +0 -1
- 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 +43 -26
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/dist/migrate/sync/index.js.map +0 -1
- package/dist/migrate/sync/schemaSync.d.ts.map +0 -1
- 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.map +0 -1
- 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,
|
|
@@ -24,6 +25,10 @@ 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']);
|
|
28
33
|
// Direct field aggregates → MongoDB accumulator. `$count` is handled separately (COUNT(*) vs
|
|
29
34
|
// COUNT(field) differ), so it is not listed here.
|
|
@@ -33,14 +38,52 @@ export class MongoDialect extends AbstractDialect {
|
|
|
33
38
|
['$min', '$min'],
|
|
34
39
|
['$max', '$max'],
|
|
35
40
|
]);
|
|
41
|
+
/**
|
|
42
|
+
* MongoDB stores the primary key as `_id`; everything else resolves as usual. Projections, sorts,
|
|
43
|
+
* `$group` refs and `$where` keys all map through here, so no read path can address a property name
|
|
44
|
+
* the document does not use.
|
|
45
|
+
*/
|
|
46
|
+
columnOf(meta, key) {
|
|
47
|
+
if (key === MongoDialect.ID_KEY || key === meta.id) {
|
|
48
|
+
return MongoDialect.ID_KEY;
|
|
49
|
+
}
|
|
50
|
+
return super.columnOf(meta, key);
|
|
51
|
+
}
|
|
36
52
|
where(entity, where = {}, opts = {}) {
|
|
37
53
|
const meta = getMeta(entity);
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
// Filters are applied once, here at the scope entry point; recursion uses `renderFilter`.
|
|
55
|
+
return this.renderFilter(entity, this.scopedWhereMap(meta, where, opts));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A `$where` that may constrain relations, split into the `$lookup` stages it needs and the `$match`
|
|
59
|
+
* filter that consumes them. Each relation condition becomes one correlated lookup into a temporary
|
|
60
|
+
* field plus an ordinary condition on that field, so the caller's boolean structure survives intact
|
|
61
|
+
* (a relation inside `$or` still means what it says) and nothing depends on materializing ids.
|
|
62
|
+
* `unset` names the temporary fields, which the caller drops once the match is done.
|
|
63
|
+
*/
|
|
64
|
+
whereWithRelations(entity, where = {}, opts = {}) {
|
|
65
|
+
const meta = getMeta(entity);
|
|
66
|
+
const lookups = { stages: [], temps: [] };
|
|
67
|
+
const filter = this.renderFilter(entity, this.scopedWhereMap(meta, where, opts), opts, lookups);
|
|
68
|
+
return { stages: lookups.stages, filter, unset: lookups.temps };
|
|
69
|
+
}
|
|
70
|
+
/** Whether a `$where` constrains any relation, and so needs the aggregation path rather than a cursor. */
|
|
71
|
+
constrainsRelations(entity, where) {
|
|
72
|
+
if (!where) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const meta = getMeta(entity);
|
|
76
|
+
const whereMap = buildQueryWhereAsMap(meta, where);
|
|
77
|
+
return Object.entries(whereMap).some(([key, val]) => key === '$and' || key === '$or'
|
|
78
|
+
? val.some((it) => this.constrainsRelations(entity, it))
|
|
79
|
+
: Boolean(meta.relations[key]));
|
|
41
80
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Renders a `$where` tree without applying entity filters (used for same-scope `$and`/`$or`
|
|
83
|
+
* recursion). Relation keys need `$lookup` stages, so they are only accepted when `lookups` is
|
|
84
|
+
* given - a plain `find`/`updateMany` filter has nowhere to put them.
|
|
85
|
+
*/
|
|
86
|
+
renderFilter(entity, where = {}, opts, lookups) {
|
|
44
87
|
const meta = getMeta(entity);
|
|
45
88
|
const whereMap = buildQueryWhereAsMap(meta, where);
|
|
46
89
|
const filter = {};
|
|
@@ -48,17 +91,27 @@ export class MongoDialect extends AbstractDialect {
|
|
|
48
91
|
let key = rawKey;
|
|
49
92
|
let val = rawVal;
|
|
50
93
|
if (key === '$and' || key === '$or') {
|
|
51
|
-
filter[key] = val.map((filterIt) =>
|
|
94
|
+
filter[key] = val.map((filterIt) => {
|
|
95
|
+
// A `QueryRaw` here would recurse forever: `buildQueryWhereAsMap` re-wraps it as
|
|
96
|
+
// `{ $and: [raw] }`, which lands back on this branch.
|
|
97
|
+
this.assertNoRaw(filterIt);
|
|
98
|
+
return this.renderFilter(entity, filterIt, opts, lookups);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else if (meta.relations[key]) {
|
|
102
|
+
this.assertNoRaw(val);
|
|
103
|
+
if (!lookups) {
|
|
104
|
+
throw new TypeError(`filtering by relation '${key}' is not supported here on MongoDB`);
|
|
105
|
+
}
|
|
106
|
+
Object.assign(filter, this.appendRelationLookup(meta, key, val, opts, lookups));
|
|
52
107
|
}
|
|
53
108
|
else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
109
|
+
this.assertNoRaw(val);
|
|
110
|
+
this.assertKnownPathRoot(meta, key);
|
|
111
|
+
key = this.pathOf(meta, key);
|
|
112
|
+
if (key === MongoDialect.ID_KEY) {
|
|
57
113
|
val = this.getIdValue(val);
|
|
58
114
|
}
|
|
59
|
-
else if (field) {
|
|
60
|
-
key = this.resolveColumnName(key, field);
|
|
61
|
-
}
|
|
62
115
|
if (isOperatorObject(val)) {
|
|
63
116
|
val = this.transformOperators(val);
|
|
64
117
|
}
|
|
@@ -70,6 +123,115 @@ export class MongoDialect extends AbstractDialect {
|
|
|
70
123
|
}
|
|
71
124
|
return filter;
|
|
72
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Emits the correlated `$lookup` for one relation condition and returns the condition that tests its
|
|
128
|
+
* result: presence of a row for a plain relation filter, a comparison against the row count for
|
|
129
|
+
* `$size`. The target's (and, for ManyToMany, the junction's) own filters scope the lookup, so a
|
|
130
|
+
* relation subquery can no more read out-of-scope rows than a direct query on the target can.
|
|
131
|
+
*/
|
|
132
|
+
appendRelationLookup(meta, relKey, val, opts, lookups) {
|
|
133
|
+
const relOpts = meta.relations[relKey];
|
|
134
|
+
const relEntity = relOpts.entity();
|
|
135
|
+
const relMeta = getMeta(relEntity);
|
|
136
|
+
const temp = `${MongoDialect.REL_TEMP_PREFIX}${lookups.temps.length}`;
|
|
137
|
+
const sizeVal = parseRelationSize(val);
|
|
138
|
+
// `$count` for a size test, `$limit: 1` for existence: neither returns the matched documents.
|
|
139
|
+
const tail = sizeVal === undefined ? [{ $limit: 1 }] : [{ $count: MongoDialect.REL_COUNT_KEY }];
|
|
140
|
+
// Scope first, render once - merging the target's filters into an already-rendered filter would
|
|
141
|
+
// leave their own keys unmapped. The caller's filter bypass is deliberately *not* passed down:
|
|
142
|
+
// `withDeleted()` or `hardDelete` on the parent must not un-hide trashed rows of the target, the
|
|
143
|
+
// same rule the SQL dialects' relation subqueries follow.
|
|
144
|
+
const targetCondition = (sizeVal === undefined ? val : {});
|
|
145
|
+
const targetScope = this.renderFilter(relEntity, this.scopedWhereMap(relMeta, targetCondition), opts);
|
|
146
|
+
lookups.temps.push(temp);
|
|
147
|
+
lookups.stages.push(relOpts.cardinality === 'mm' && relOpts.through
|
|
148
|
+
? this.junctionLookup(meta, relOpts, relMeta, relEntity, targetScope, temp, tail, opts)
|
|
149
|
+
: {
|
|
150
|
+
$lookup: {
|
|
151
|
+
from: this.resolveTableName(relEntity, relMeta),
|
|
152
|
+
...this.joinKeys(meta, relMeta, relOpts),
|
|
153
|
+
pipeline: [...(hasKeys(targetScope) ? [{ $match: targetScope }] : []), ...tail],
|
|
154
|
+
as: temp,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
return sizeVal === undefined
|
|
158
|
+
? { [`${temp}.0`]: { $exists: true } }
|
|
159
|
+
: { $expr: this.compareRelationCount(temp, sizeVal) };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* ManyToMany counts/tests junction rows, so the target is reached from inside the junction's own
|
|
163
|
+
* lookup - the junction's filters apply too, since a soft-deleted link is not a link.
|
|
164
|
+
*/
|
|
165
|
+
junctionLookup(meta, relOpts, relMeta, relEntity, targetScope, temp, tail, opts) {
|
|
166
|
+
const throughEntity = relOpts.through();
|
|
167
|
+
const throughMeta = getMeta(throughEntity);
|
|
168
|
+
const junctionScope = this.renderFilter(throughEntity, this.scopedWhereMap(throughMeta, {}), opts);
|
|
169
|
+
const nested = MongoDialect.REL_NESTED_KEY;
|
|
170
|
+
return {
|
|
171
|
+
$lookup: {
|
|
172
|
+
from: this.resolveTableName(throughEntity, throughMeta),
|
|
173
|
+
localField: MongoDialect.ID_KEY,
|
|
174
|
+
foreignField: this.columnOf(throughMeta, relOpts.references[0].local),
|
|
175
|
+
pipeline: [
|
|
176
|
+
...(hasKeys(junctionScope) ? [{ $match: junctionScope }] : []),
|
|
177
|
+
{
|
|
178
|
+
$lookup: {
|
|
179
|
+
from: this.resolveTableName(relEntity, relMeta),
|
|
180
|
+
localField: this.columnOf(throughMeta, relOpts.references[1].local),
|
|
181
|
+
foreignField: MongoDialect.ID_KEY,
|
|
182
|
+
pipeline: [...(hasKeys(targetScope) ? [{ $match: targetScope }] : []), { $limit: 1 }],
|
|
183
|
+
as: nested,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{ $match: { [`${nested}.0`]: { $exists: true } } },
|
|
187
|
+
...tail,
|
|
188
|
+
],
|
|
189
|
+
as: temp,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Compares the looked-up row count, which is `[{ n: <count> }]` or `[]` when nothing matched - hence
|
|
195
|
+
* the `$ifNull` fallback to 0, so `{ $size: 0 }` matches parents with no related row at all.
|
|
196
|
+
*/
|
|
197
|
+
compareRelationCount(temp, sizeVal) {
|
|
198
|
+
const count = { $ifNull: [{ $arrayElemAt: [`$${temp}.${MongoDialect.REL_COUNT_KEY}`, 0] }, 0] };
|
|
199
|
+
if (typeof sizeVal === 'number') {
|
|
200
|
+
return { $eq: [count, sizeVal] };
|
|
201
|
+
}
|
|
202
|
+
const comparisons = Object.entries(sizeVal)
|
|
203
|
+
.filter(([, bound]) => bound !== undefined)
|
|
204
|
+
.flatMap(([op, bound]) => op === '$between'
|
|
205
|
+
? [{ $gte: [count, bound[0]] }, { $lte: [count, bound[1]] }]
|
|
206
|
+
: [{ [op]: [count, bound] }]);
|
|
207
|
+
if (!comparisons.length) {
|
|
208
|
+
throw new TypeError('$size on a relation needs at least one comparison');
|
|
209
|
+
}
|
|
210
|
+
return comparisons.length === 1 ? comparisons[0] : { $and: comparisons };
|
|
211
|
+
}
|
|
212
|
+
/** Whether a query subtracts `key` from the projection, via `$exclude` or a negative `$select`. */
|
|
213
|
+
subtractsKey(key, select, exclude) {
|
|
214
|
+
const at = (map) => map?.[key];
|
|
215
|
+
return at(exclude) === true || at(select) === false;
|
|
216
|
+
}
|
|
217
|
+
/** `raw()` renders SQL, so it has no MongoDB equivalent - say so instead of emitting `{}`. */
|
|
218
|
+
assertNoRaw(value) {
|
|
219
|
+
if (value instanceof QueryRaw) {
|
|
220
|
+
throw new TypeError('raw() in $where is not supported on MongoDB');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* A dotted key addresses an embedded path, whose root must still be a declared field - otherwise it
|
|
225
|
+
* is a typo (or an injected key) that would silently match nothing, the same guard the SQL dialects
|
|
226
|
+
* apply to JSON paths.
|
|
227
|
+
*/
|
|
228
|
+
assertKnownPathRoot(meta, key) {
|
|
229
|
+
const root = key.includes('.') ? key.slice(0, key.indexOf('.')) : key;
|
|
230
|
+
if (root === MongoDialect.ID_KEY || root === meta.id || meta.fields[root]) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
throw new TypeError(`path ${key} does not exist in ${meta.name ?? ''}`);
|
|
234
|
+
}
|
|
73
235
|
mapTableNameRow(row) {
|
|
74
236
|
return row.table_name;
|
|
75
237
|
}
|
|
@@ -168,87 +330,145 @@ export class MongoDialect extends AbstractDialect {
|
|
|
168
330
|
if (Array.isArray(select)) {
|
|
169
331
|
throw new TypeError('raw $select is not supported on MongoDB');
|
|
170
332
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
333
|
+
const selectMap = asSelectMap(select);
|
|
334
|
+
// Projected by column, not by field key; `normalizeId` maps them back on the way out.
|
|
335
|
+
const projection = normalizeScalarFieldSelection(meta, selectMap, exclude).reduce((acc, key) => {
|
|
336
|
+
acc[this.columnOf(meta, key)] = 1;
|
|
174
337
|
return acc;
|
|
175
338
|
}, {});
|
|
339
|
+
// MongoDB returns `_id` unless it is explicitly excluded, so subtracting the primary key needs
|
|
340
|
+
// `_id: 0` - the one inclusion/exclusion mix MongoDB allows - or `$exclude: { id: true }` would
|
|
341
|
+
// have no effect at all.
|
|
342
|
+
if (this.subtractsKey(meta.id, selectMap, exclude)) {
|
|
343
|
+
projection[MongoDialect.ID_KEY] = 0;
|
|
344
|
+
}
|
|
345
|
+
return projection;
|
|
176
346
|
}
|
|
177
347
|
sort(entity, sort) {
|
|
178
|
-
const
|
|
348
|
+
const meta = getMeta(entity);
|
|
349
|
+
return this.sortBy(sort, (key) => {
|
|
350
|
+
if (meta.relations[key]) {
|
|
351
|
+
throw new TypeError(`sorting by relation '${key}' is not supported on MongoDB`);
|
|
352
|
+
}
|
|
353
|
+
return this.pathOf(meta, key);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Aggregate results are keyed by `$group`/`$agg` alias rather than by column, so an aggregate
|
|
358
|
+
* `$sort` addresses those aliases as-is - the same reason the SQL dialects sort by alias there.
|
|
359
|
+
*/
|
|
360
|
+
aliasSort(sort) {
|
|
361
|
+
return this.sortBy(sort, (alias) => alias);
|
|
362
|
+
}
|
|
363
|
+
/** Shared direction normalization; `mapKey` decides whether keys are columns or aggregate aliases. */
|
|
364
|
+
sortBy(sort, mapKey) {
|
|
179
365
|
const normalized = {};
|
|
180
|
-
for (const [key, dir] of Object.entries(
|
|
181
|
-
normalized[key] = dir === 'desc' || dir === -1 ? -1 : 1;
|
|
366
|
+
for (const [key, dir] of Object.entries(buildSortMap(sort))) {
|
|
367
|
+
normalized[mapKey(key)] = dir === 'desc' || dir === -1 ? -1 : 1;
|
|
182
368
|
}
|
|
183
369
|
return normalized;
|
|
184
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* {@link columnOf} for a possibly dotted key: only the root is a field key, the rest addresses an
|
|
373
|
+
* embedded path (`kind.city` -> `<kind's column>.city`).
|
|
374
|
+
*/
|
|
375
|
+
pathOf(meta, key) {
|
|
376
|
+
const dot = key.indexOf('.');
|
|
377
|
+
if (dot < 0) {
|
|
378
|
+
return this.columnOf(meta, key);
|
|
379
|
+
}
|
|
380
|
+
return this.columnOf(meta, key.slice(0, dot)) + key.slice(dot);
|
|
381
|
+
}
|
|
185
382
|
aggregationPipeline(entity, q, relationSummary, opts) {
|
|
186
|
-
const
|
|
187
|
-
const where = this.where(entity, q.$where, opts);
|
|
383
|
+
const { stages, filter, unset } = this.whereWithRelations(entity, q.$where, opts);
|
|
188
384
|
const sort = this.sort(entity, q.$sort);
|
|
189
|
-
const
|
|
190
|
-
if (hasKeys(
|
|
191
|
-
|
|
385
|
+
const match = {};
|
|
386
|
+
if (hasKeys(filter)) {
|
|
387
|
+
match.$match = filter;
|
|
192
388
|
}
|
|
193
389
|
if (hasKeys(sort)) {
|
|
194
|
-
|
|
195
|
-
}
|
|
390
|
+
match.$sort = sort;
|
|
391
|
+
}
|
|
392
|
+
// Lookups that a relation condition needs come first, then the match that reads them, then the
|
|
393
|
+
// temporary fields are dropped so they never reach the caller.
|
|
394
|
+
const pipeline = [...stages];
|
|
395
|
+
if (hasKeys(match)) {
|
|
396
|
+
pipeline.push(match);
|
|
397
|
+
}
|
|
398
|
+
if (unset.length) {
|
|
399
|
+
pipeline.push({ $unset: unset });
|
|
400
|
+
}
|
|
401
|
+
const relStages = this.relationStages(entity, q, relationSummary, opts);
|
|
402
|
+
const pager = [
|
|
403
|
+
...(q.$skip === undefined ? [] : [{ $skip: q.$skip }]),
|
|
404
|
+
...(q.$limit === undefined ? [] : [{ $limit: q.$limit }]),
|
|
405
|
+
];
|
|
406
|
+
// A `$required` relation drops parents when it unwinds, so paging has to come after it - as it
|
|
407
|
+
// does after an INNER JOIN. Otherwise paging first is equivalent and spares the lookups.
|
|
408
|
+
const dropsParents = relStages.some((stage) => stage.$unwind?.preserveNullAndEmptyArrays === false);
|
|
409
|
+
pipeline.push(...(dropsParents ? [...relStages, ...pager] : [...pager, ...relStages]));
|
|
410
|
+
return pipeline;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* `$lookup`/`$unwind` stages for the joinable relations a query populates. Shared by the plain
|
|
414
|
+
* aggregation pipeline and the `$vectorSearch` one, so relations load the same way in both.
|
|
415
|
+
*/
|
|
416
|
+
relationStages(entity, q, relationSummary, opts) {
|
|
417
|
+
const meta = getMeta(entity);
|
|
196
418
|
const pipeline = [];
|
|
197
|
-
if (hasKeys(firstPipelineEntry)) {
|
|
198
|
-
pipeline.push(firstPipelineEntry);
|
|
199
|
-
}
|
|
200
419
|
const relKeys = (relationSummary ?? getRelationRequestSummary(meta, q.$populate)).joinableKeys;
|
|
201
420
|
for (const relKey of relKeys) {
|
|
202
421
|
const relOpts = meta.relations[relKey];
|
|
203
422
|
if (!relOpts)
|
|
204
423
|
continue;
|
|
205
424
|
if (relOpts.cardinality === '1m' || relOpts.cardinality === 'mm') {
|
|
206
|
-
// '1m' and 'mm'
|
|
425
|
+
// '1m' and 'mm' are resolved in a higher layer: they need a second query each.
|
|
207
426
|
continue;
|
|
208
427
|
}
|
|
209
428
|
const relEntity = relOpts.entity();
|
|
210
429
|
const relMeta = getMeta(relEntity);
|
|
430
|
+
const { query: relQuery, required } = parseRelationAtKey(relKey, q.$populate);
|
|
211
431
|
// Unconditional, not gated by an explicit relation-level `$where`: the related entity's own
|
|
212
432
|
// filters (in particular `security: true` ones) must apply even to a bare
|
|
213
433
|
// `$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 } });
|
|
434
|
+
const relationFilter = this.where(relEntity, relQuery.$where ?? {}, opts);
|
|
435
|
+
pipeline.push({
|
|
436
|
+
$lookup: {
|
|
437
|
+
from: this.resolveTableName(relEntity, relMeta),
|
|
438
|
+
...this.joinKeys(meta, relMeta, relOpts),
|
|
439
|
+
...(hasKeys(relationFilter) ? { pipeline: [{ $match: relationFilter }] } : {}),
|
|
440
|
+
as: relKey,
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
// `$required` drops parents with no match, the aggregation equivalent of an INNER JOIN.
|
|
444
|
+
pipeline.push({ $unwind: { path: `$${relKey}`, preserveNullAndEmptyArrays: !required } });
|
|
249
445
|
}
|
|
250
446
|
return pipeline;
|
|
251
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* The correlated join for a single-valued or one-to-many relation. MongoDB runs a lookup's `pipeline`
|
|
450
|
+
* after its own localField/foreignField match, so the target's filters layer on top of the join
|
|
451
|
+
* condition with no `let`/`$expr` rewrite: m1 joins the parent's FK to the target's `_id`, every other
|
|
452
|
+
* direction joins the parent's `_id` to the target's FK.
|
|
453
|
+
*/
|
|
454
|
+
joinKeys(meta, relMeta, relOpts) {
|
|
455
|
+
return relOpts.cardinality === 'm1'
|
|
456
|
+
? { localField: this.columnOf(meta, relOpts.references[0].local), foreignField: MongoDialect.ID_KEY }
|
|
457
|
+
: { localField: MongoDialect.ID_KEY, foreignField: this.columnOf(relMeta, relOpts.references[0].foreign) };
|
|
458
|
+
}
|
|
459
|
+
/** `[column, key]` for the fields whose stored name differs from their property name, memoized per entity. */
|
|
460
|
+
renamedColumns(meta) {
|
|
461
|
+
let renamed = this.#renamedColumns.get(meta);
|
|
462
|
+
if (!renamed) {
|
|
463
|
+
renamed = getKeys(meta.fields)
|
|
464
|
+
.map((key) => [this.columnOf(meta, key), key])
|
|
465
|
+
.filter(([column, key]) => column !== key);
|
|
466
|
+
this.#renamedColumns.set(meta, renamed);
|
|
467
|
+
}
|
|
468
|
+
return renamed;
|
|
469
|
+
}
|
|
470
|
+
// Keyed by the meta object itself; entity metadata is immutable once defined.
|
|
471
|
+
#renamedColumns = new WeakMap();
|
|
252
472
|
normalizeIds(meta, docs) {
|
|
253
473
|
return docs?.map((doc) => this.normalizeId(meta, doc));
|
|
254
474
|
}
|
|
@@ -264,12 +484,12 @@ export class MongoDialect extends AbstractDialect {
|
|
|
264
484
|
delete res[_id];
|
|
265
485
|
}
|
|
266
486
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
res[key] = res[
|
|
272
|
-
delete res[
|
|
487
|
+
// Only the renamed fields need touching, and which those are is a property of the entity, not of
|
|
488
|
+
// the document - so it is derived once instead of for every row of a result set.
|
|
489
|
+
for (const [column, key] of this.renamedColumns(meta)) {
|
|
490
|
+
if (res[column] !== undefined) {
|
|
491
|
+
res[key] = res[column];
|
|
492
|
+
delete res[column];
|
|
273
493
|
}
|
|
274
494
|
}
|
|
275
495
|
const relKeys = getKeys(meta.relations).filter((key) => res[key]);
|
|
@@ -398,7 +618,7 @@ export class MongoDialect extends AbstractDialect {
|
|
|
398
618
|
}
|
|
399
619
|
}
|
|
400
620
|
// $group stage
|
|
401
|
-
const { groupId, groupAccumulators, distinctReducers } = this.buildGroupSpec(parseGroupMap(q.$group, q.$agg));
|
|
621
|
+
const { groupId, groupAccumulators, distinctReducers } = this.buildGroupSpec(getMeta(entity), parseGroupMap(q.$group, q.$agg));
|
|
402
622
|
pipeline.push({ $group: { _id: hasKeys(groupId) ? groupId : null, ...groupAccumulators } });
|
|
403
623
|
// Project stage - rename _id fields back to their original names, and reduce collected distinct
|
|
404
624
|
// sets. Needed whenever there are group keys OR any distinct alias.
|
|
@@ -420,9 +640,9 @@ export class MongoDialect extends AbstractDialect {
|
|
|
420
640
|
pipeline.push({ $match: havingFilter });
|
|
421
641
|
}
|
|
422
642
|
}
|
|
423
|
-
// $sort stage
|
|
643
|
+
// $sort stage - by alias, since $group/$project already renamed everything
|
|
424
644
|
if (q.$sort) {
|
|
425
|
-
const sort = this.
|
|
645
|
+
const sort = this.aliasSort(q.$sort);
|
|
426
646
|
if (hasKeys(sort)) {
|
|
427
647
|
pipeline.push({ $sort: sort });
|
|
428
648
|
}
|
|
@@ -441,7 +661,7 @@ export class MongoDialect extends AbstractDialect {
|
|
|
441
661
|
* `distinctReducers` maps each DISTINCT alias (collected via `$addToSet`) to the `$project`
|
|
442
662
|
* operator that reduces its set: `$size` for `$count`, `$sum`/`$avg` for the numeric ops.
|
|
443
663
|
*/
|
|
444
|
-
buildGroupSpec(groupEntries) {
|
|
664
|
+
buildGroupSpec(meta, groupEntries) {
|
|
445
665
|
if (!groupEntries.length) {
|
|
446
666
|
throw new TypeError('aggregate requires at least one $group column or $agg function');
|
|
447
667
|
}
|
|
@@ -449,25 +669,27 @@ export class MongoDialect extends AbstractDialect {
|
|
|
449
669
|
const groupAccumulators = {};
|
|
450
670
|
const distinctReducers = new Map();
|
|
451
671
|
for (const entry of groupEntries) {
|
|
672
|
+
// Aliases stay as the caller wrote them ($project maps them back); the *refs* address columns.
|
|
673
|
+
const ref = entry.kind === 'key' ? `$${this.columnOf(meta, entry.alias)}` : `$${this.columnOf(meta, entry.fieldRef)}`;
|
|
452
674
|
if (entry.kind === 'key') {
|
|
453
|
-
groupId[entry.alias] =
|
|
675
|
+
groupId[entry.alias] = ref;
|
|
454
676
|
}
|
|
455
677
|
else if (entry.distinct) {
|
|
456
678
|
// Collect the set now; reduce it in $project: `$size` counts it, `$sum`/`$avg` reduce the array.
|
|
457
|
-
groupAccumulators[entry.alias] = { $addToSet:
|
|
679
|
+
groupAccumulators[entry.alias] = { $addToSet: ref };
|
|
458
680
|
distinctReducers.set(entry.alias, entry.op === '$count' ? '$size' : entry.op);
|
|
459
681
|
}
|
|
460
682
|
else if (entry.op === '$count') {
|
|
461
683
|
// COUNT(*) counts every row; COUNT(field) counts non-null values, matching SQL.
|
|
462
684
|
groupAccumulators[entry.alias] =
|
|
463
|
-
entry.fieldRef === '*' ? { $sum: 1 } : { $sum: { $cond: [{ $ne: [
|
|
685
|
+
entry.fieldRef === '*' ? { $sum: 1 } : { $sum: { $cond: [{ $ne: [ref, null] }, 1, 0] } };
|
|
464
686
|
}
|
|
465
687
|
else {
|
|
466
688
|
const mongoOp = MongoDialect.AGGREGATE_OP_MAP.get(entry.op);
|
|
467
689
|
if (!mongoOp) {
|
|
468
690
|
throw TypeError(`unsupported aggregate operator: ${entry.op}`);
|
|
469
691
|
}
|
|
470
|
-
groupAccumulators[entry.alias] = { [mongoOp]:
|
|
692
|
+
groupAccumulators[entry.alias] = { [mongoOp]: ref };
|
|
471
693
|
}
|
|
472
694
|
}
|
|
473
695
|
return { groupId, groupAccumulators, distinctReducers };
|
|
@@ -541,4 +763,3 @@ export class MongoDialect extends AbstractDialect {
|
|
|
541
763
|
return { $vectorSearch: stage };
|
|
542
764
|
}
|
|
543
765
|
}
|
|
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
|