@gravito/echo 3.0.0 → 3.1.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 +211 -0
- package/dist/atlas/src/DB.d.ts +301 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +48 -0
- package/dist/atlas/src/connection/Connection.d.ts +108 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +67 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/index.d.ts +5 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +449 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/types/index.d.ts +1100 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/Application.d.ts +215 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +26 -0
- package/dist/core/src/Container.d.ts +108 -0
- package/dist/core/src/ErrorHandler.d.ts +63 -0
- package/dist/core/src/Event.d.ts +5 -0
- package/dist/core/src/EventManager.d.ts +123 -0
- package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
- package/dist/core/src/GravitoServer.d.ts +28 -0
- package/dist/core/src/HookManager.d.ts +496 -0
- package/dist/core/src/Listener.d.ts +4 -0
- package/dist/core/src/Logger.d.ts +20 -0
- package/dist/core/src/PlanetCore.d.ts +289 -0
- package/dist/core/src/Route.d.ts +36 -0
- package/dist/core/src/Router.d.ts +284 -0
- package/dist/core/src/ServiceProvider.d.ts +156 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +171 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +45 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +31 -0
- package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
- package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +31 -0
- package/dist/core/src/adapters/bun/types.d.ts +20 -0
- package/dist/core/src/adapters/photon-types.d.ts +73 -0
- package/dist/core/src/adapters/types.d.ts +235 -0
- package/dist/core/src/engine/AOTRouter.d.ts +124 -0
- package/dist/core/src/engine/FastContext.d.ts +100 -0
- package/dist/core/src/engine/Gravito.d.ts +137 -0
- package/dist/core/src/engine/MinimalContext.d.ts +79 -0
- package/dist/core/src/engine/analyzer.d.ts +27 -0
- package/dist/core/src/engine/constants.d.ts +23 -0
- package/dist/core/src/engine/index.d.ts +26 -0
- package/dist/core/src/engine/path.d.ts +26 -0
- package/dist/core/src/engine/pool.d.ts +83 -0
- package/dist/core/src/engine/types.d.ts +143 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
- package/dist/core/src/events/EventBackend.d.ts +11 -0
- package/dist/core/src/events/EventOptions.d.ts +109 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/index.d.ts +14 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/index.d.ts +20 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +75 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
- package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
- package/dist/core/src/exceptions/HttpException.d.ts +9 -0
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
- package/dist/core/src/exceptions/index.d.ts +7 -0
- package/dist/core/src/helpers/Arr.d.ts +19 -0
- package/dist/core/src/helpers/Str.d.ts +23 -0
- package/dist/core/src/helpers/data.d.ts +25 -0
- package/dist/core/src/helpers/errors.d.ts +34 -0
- package/dist/core/src/helpers/response.d.ts +41 -0
- package/dist/core/src/helpers.d.ts +338 -0
- package/dist/core/src/http/CookieJar.d.ts +51 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +16 -0
- package/dist/core/src/http/middleware/Cors.d.ts +24 -0
- package/dist/core/src/http/middleware/Csrf.d.ts +23 -0
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +28 -0
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +29 -0
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +18 -0
- package/dist/core/src/http/types.d.ts +355 -0
- package/dist/core/src/index.d.ts +76 -0
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/core/src/runtime.d.ts +119 -0
- package/dist/core/src/security/Encrypter.d.ts +33 -0
- package/dist/core/src/security/Hasher.d.ts +29 -0
- package/dist/core/src/testing/HttpTester.d.ts +39 -0
- package/dist/core/src/testing/TestResponse.d.ts +78 -0
- package/dist/core/src/testing/index.d.ts +2 -0
- package/dist/core/src/types/events.d.ts +94 -0
- package/dist/echo/src/OrbitEcho.d.ts +115 -0
- package/dist/echo/src/dlq/DeadLetterQueue.d.ts +94 -0
- package/dist/echo/src/dlq/MemoryDeadLetterQueue.d.ts +36 -0
- package/dist/echo/src/dlq/index.d.ts +2 -0
- package/dist/echo/src/index.d.ts +64 -0
- package/dist/echo/src/middleware/RequestBufferMiddleware.d.ts +62 -0
- package/dist/echo/src/middleware/index.d.ts +8 -0
- package/dist/echo/src/observability/index.d.ts +3 -0
- package/dist/echo/src/observability/logging/ConsoleEchoLogger.d.ts +37 -0
- package/dist/echo/src/observability/logging/EchoLogger.d.ts +38 -0
- package/dist/echo/src/observability/logging/index.d.ts +2 -0
- package/dist/echo/src/observability/metrics/MetricsProvider.d.ts +69 -0
- package/dist/echo/src/observability/metrics/NoopMetricsProvider.d.ts +17 -0
- package/dist/echo/src/observability/metrics/PrometheusMetricsProvider.d.ts +39 -0
- package/dist/echo/src/observability/metrics/index.d.ts +3 -0
- package/dist/echo/src/observability/tracing/NoopTracer.d.ts +33 -0
- package/dist/echo/src/observability/tracing/Tracer.d.ts +75 -0
- package/dist/echo/src/observability/tracing/index.d.ts +2 -0
- package/dist/echo/src/providers/GenericProvider.d.ts +53 -0
- package/dist/echo/src/providers/GitHubProvider.d.ts +35 -0
- package/dist/echo/src/providers/LinearProvider.d.ts +27 -0
- package/dist/echo/src/providers/PaddleProvider.d.ts +31 -0
- package/dist/echo/src/providers/ShopifyProvider.d.ts +27 -0
- package/dist/echo/src/providers/SlackProvider.d.ts +27 -0
- package/dist/echo/src/providers/StripeProvider.d.ts +38 -0
- package/dist/echo/src/providers/TwilioProvider.d.ts +31 -0
- package/dist/echo/src/providers/base/BaseProvider.d.ts +87 -0
- package/dist/echo/src/providers/base/HeaderUtils.d.ts +34 -0
- package/dist/echo/src/providers/index.d.ts +14 -0
- package/dist/echo/src/receive/SignatureValidator.d.ts +67 -0
- package/dist/echo/src/receive/WebhookReceiver.d.ts +185 -0
- package/dist/echo/src/receive/index.d.ts +2 -0
- package/dist/echo/src/replay/WebhookReplayService.d.ts +35 -0
- package/dist/echo/src/replay/index.d.ts +1 -0
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +117 -0
- package/dist/echo/src/resilience/index.d.ts +10 -0
- package/dist/echo/src/rotation/KeyRotationManager.d.ts +127 -0
- package/dist/echo/src/rotation/index.d.ts +10 -0
- package/dist/echo/src/send/WebhookDispatcher.d.ts +198 -0
- package/dist/echo/src/send/index.d.ts +1 -0
- package/dist/echo/src/storage/MemoryWebhookStore.d.ts +14 -0
- package/dist/echo/src/storage/WebhookStore.d.ts +236 -0
- package/dist/echo/src/storage/index.d.ts +2 -0
- package/dist/echo/src/types.d.ts +756 -0
- package/dist/index.js +1332 -190
- package/dist/index.js.map +28 -10
- package/dist/photon/src/index.d.ts +84 -0
- package/dist/photon/src/middleware/binary.d.ts +31 -0
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/package.json +7 -5
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import type { Model, ModelConstructor } from '../orm/model/Model';
|
|
2
|
+
import type { BooleanOperator, CompiledQuery, ConnectionContract, GrammarContract, JoinType, Operator, OrderDirection, PaginateResult, QueryBuilderContract } from '../types';
|
|
3
|
+
import { GroupByClause, HavingClause, JoinManager, LimitClause, OrderByClause, SelectClause, WhereClause } from './clauses';
|
|
4
|
+
import { Expression } from './Expression';
|
|
5
|
+
export declare class QueryBuilderError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class RecordNotFoundError extends Error {
|
|
9
|
+
constructor(message?: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fluent Query Builder for constructing SQL queries.
|
|
13
|
+
*
|
|
14
|
+
* Provides a chainable interface for building complex SELECT, INSERT, UPDATE,
|
|
15
|
+
* and DELETE statements. Supports advanced features like subqueries, joins,
|
|
16
|
+
* global scopes, and copy-on-write optimization.
|
|
17
|
+
*
|
|
18
|
+
* @template T - The structure of the resulting records.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const users = await DB.table<User>('users')
|
|
23
|
+
* .select('id', 'name')
|
|
24
|
+
* .where('status', 'active')
|
|
25
|
+
* .orderBy('created_at', 'desc')
|
|
26
|
+
* .limit(10)
|
|
27
|
+
* .get();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class QueryBuilder<T = Record<string, unknown>> implements QueryBuilderContract<T> {
|
|
31
|
+
protected readonly connection: ConnectionContract;
|
|
32
|
+
protected readonly grammar: GrammarContract;
|
|
33
|
+
/**
|
|
34
|
+
* Name of the target database table.
|
|
35
|
+
*/
|
|
36
|
+
protected tableName: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional Model class for result hydration.
|
|
39
|
+
*/
|
|
40
|
+
protected modelClass?: ModelConstructor<Model>;
|
|
41
|
+
protected selectClause: SelectClause;
|
|
42
|
+
protected whereClause: WhereClause;
|
|
43
|
+
protected joinManager: JoinManager;
|
|
44
|
+
protected groupByClause: GroupByClause;
|
|
45
|
+
protected havingClause: HavingClause;
|
|
46
|
+
protected orderByClause: OrderByClause;
|
|
47
|
+
protected limitClause: LimitClause;
|
|
48
|
+
/**
|
|
49
|
+
* Read-only flag to bypass hydration for performance.
|
|
50
|
+
*/
|
|
51
|
+
protected isReadOnly: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Map of relationships to load alongside query results.
|
|
54
|
+
*/
|
|
55
|
+
protected eagerLoads: Map<string, (query: QueryBuilderContract<any>) => void>;
|
|
56
|
+
/**
|
|
57
|
+
* Result caching configuration.
|
|
58
|
+
*/
|
|
59
|
+
protected _cache?: {
|
|
60
|
+
ttl: number;
|
|
61
|
+
key?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Internal flag for copy-on-write optimization.
|
|
65
|
+
*/
|
|
66
|
+
protected _isClone: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Tracks if clones have been modified.
|
|
69
|
+
*/
|
|
70
|
+
protected _isModified: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Tracks reference counts for shared state management.
|
|
73
|
+
*/
|
|
74
|
+
private _cloneCount;
|
|
75
|
+
/**
|
|
76
|
+
* Registered global query filters.
|
|
77
|
+
*/
|
|
78
|
+
protected globalScopes: Map<string, (query: QueryBuilderContract<any>) => void>;
|
|
79
|
+
/**
|
|
80
|
+
* Identifiers of scopes to bypass.
|
|
81
|
+
*/
|
|
82
|
+
protected removedScopes: Set<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Prevents infinite recursion during scope application.
|
|
85
|
+
*/
|
|
86
|
+
protected _isApplyingScopes: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Initializes a new query builder.
|
|
89
|
+
*
|
|
90
|
+
* @param connection - Active database connection.
|
|
91
|
+
* @param grammar - SQL compiler instance.
|
|
92
|
+
* @param table - Initial table name.
|
|
93
|
+
*/
|
|
94
|
+
constructor(connection: ConnectionContract, grammar: GrammarContract, table: string);
|
|
95
|
+
/**
|
|
96
|
+
* Implements Copy-on-Write for query cloning.
|
|
97
|
+
*
|
|
98
|
+
* Shared state (clauses) is lazily copied only when a modification occurs.
|
|
99
|
+
* This drastically reduces overhead for operations like .count() or .paginate()
|
|
100
|
+
* that require cloning the builder.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
protected ensureOwnState(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Associates a Model with the query for automatic record hydration.
|
|
107
|
+
*
|
|
108
|
+
* @param model - The Model class constructor.
|
|
109
|
+
*/
|
|
110
|
+
setModel<M extends Model>(model: ModelConstructor<M>): this;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves the associated Model class.
|
|
113
|
+
*/
|
|
114
|
+
getModel<M extends Model>(): ModelConstructor<M> | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Accesses raw WHERE conditions.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
get wheres(): import('./clauses/WhereClause').WhereCondition[];
|
|
120
|
+
/**
|
|
121
|
+
* Specifies the columns to be retrieved.
|
|
122
|
+
*
|
|
123
|
+
* @param columns - List of column names.
|
|
124
|
+
*/
|
|
125
|
+
select(...columns: string[]): this;
|
|
126
|
+
/**
|
|
127
|
+
* Sets the target database table.
|
|
128
|
+
*/
|
|
129
|
+
from(table: string): this;
|
|
130
|
+
/**
|
|
131
|
+
* Adds a raw SQL expression to the SELECT clause.
|
|
132
|
+
*
|
|
133
|
+
* @param sql - Raw SQL template or Expression instance.
|
|
134
|
+
* @param bindings - Binding values.
|
|
135
|
+
*/
|
|
136
|
+
selectRaw(sql: string | Expression, bindings?: unknown[]): this;
|
|
137
|
+
/**
|
|
138
|
+
* Adds the DISTINCT keyword to the selection.
|
|
139
|
+
*/
|
|
140
|
+
distinct(): this;
|
|
141
|
+
/**
|
|
142
|
+
* Configures query result caching.
|
|
143
|
+
*
|
|
144
|
+
* @param ttl - Duration in seconds.
|
|
145
|
+
* @param key - Explicit cache identifier.
|
|
146
|
+
*/
|
|
147
|
+
cache(ttl: number, key?: string): this;
|
|
148
|
+
/**
|
|
149
|
+
* Adds a WHERE constraint to the query.
|
|
150
|
+
*
|
|
151
|
+
* Supports various formats:
|
|
152
|
+
* - Key-value object: .where({ id: 1, active: true })
|
|
153
|
+
* - Operator form: .where('age', '>', 18)
|
|
154
|
+
* - Nested closure: .where(q => q.where('a', 1).orWhere('b', 2))
|
|
155
|
+
*
|
|
156
|
+
* @param column - Column name, closure, or object.
|
|
157
|
+
* @param operatorOrValue - Comparison operator or value.
|
|
158
|
+
* @param value - Value (if operator is provided).
|
|
159
|
+
*/
|
|
160
|
+
where(column: string | ((query: QueryBuilderContract<T>) => void) | Record<string, unknown>, operatorOrValue?: Operator | unknown, value?: unknown): this;
|
|
161
|
+
/**
|
|
162
|
+
* Adds an OR WHERE constraint.
|
|
163
|
+
*/
|
|
164
|
+
orWhere(column: string | ((query: QueryBuilderContract<T>) => void), operatorOrValue?: Operator | unknown, value?: unknown): this;
|
|
165
|
+
/**
|
|
166
|
+
* Adds a WHERE IN constraint.
|
|
167
|
+
*
|
|
168
|
+
* @param column - Target column.
|
|
169
|
+
* @param values - Values array or subquery.
|
|
170
|
+
*/
|
|
171
|
+
whereIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
|
|
172
|
+
/**
|
|
173
|
+
* Adds a WHERE NOT IN constraint.
|
|
174
|
+
*/
|
|
175
|
+
whereNotIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
|
|
176
|
+
/**
|
|
177
|
+
* Adds an OR WHERE IN constraint.
|
|
178
|
+
*/
|
|
179
|
+
orWhereIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
|
|
180
|
+
/**
|
|
181
|
+
* Adds an OR WHERE NOT IN constraint.
|
|
182
|
+
*/
|
|
183
|
+
orWhereNotIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
|
|
184
|
+
/**
|
|
185
|
+
* Adds a WHERE column IS NULL constraint.
|
|
186
|
+
*/
|
|
187
|
+
whereNull(column: string): this;
|
|
188
|
+
/**
|
|
189
|
+
* Adds a WHERE column IS NOT NULL constraint.
|
|
190
|
+
*/
|
|
191
|
+
whereNotNull(column: string): this;
|
|
192
|
+
/**
|
|
193
|
+
* Adds an OR WHERE column IS NULL constraint.
|
|
194
|
+
*/
|
|
195
|
+
orWhereNull(column: string): this;
|
|
196
|
+
/**
|
|
197
|
+
* Adds an OR WHERE column IS NOT NULL constraint.
|
|
198
|
+
*/
|
|
199
|
+
orWhereNotNull(column: string): this;
|
|
200
|
+
/**
|
|
201
|
+
* Adds a WHERE BETWEEN constraint.
|
|
202
|
+
*/
|
|
203
|
+
whereBetween(column: string, values: [unknown, unknown]): this;
|
|
204
|
+
/**
|
|
205
|
+
* Adds a WHERE NOT BETWEEN constraint.
|
|
206
|
+
*/
|
|
207
|
+
whereNotBetween(column: string, values: [unknown, unknown]): this;
|
|
208
|
+
/**
|
|
209
|
+
* Adds a raw SQL WHERE constraint.
|
|
210
|
+
*/
|
|
211
|
+
whereRaw(sql: string | Expression, bindings?: unknown[]): this;
|
|
212
|
+
/**
|
|
213
|
+
* Adds an OR WHERE raw SQL constraint.
|
|
214
|
+
*/
|
|
215
|
+
orWhereRaw(sql: string | Expression, bindings?: unknown[]): this;
|
|
216
|
+
/**
|
|
217
|
+
* Compares two columns in a WHERE clause.
|
|
218
|
+
*/
|
|
219
|
+
whereColumn(first: string, operator: Operator, second: string): this;
|
|
220
|
+
/**
|
|
221
|
+
* Adds a WHERE EXISTS subquery constraint.
|
|
222
|
+
*
|
|
223
|
+
* @param callback - Logic for the subquery.
|
|
224
|
+
*/
|
|
225
|
+
whereExists(callback: (query: QueryBuilderContract<any>) => void): this;
|
|
226
|
+
/**
|
|
227
|
+
* Adds a WHERE NOT EXISTS subquery constraint.
|
|
228
|
+
*/
|
|
229
|
+
whereNotExists(callback: (query: QueryBuilderContract<any>) => void): this;
|
|
230
|
+
/**
|
|
231
|
+
* Adds a constraint for a nested JSON property.
|
|
232
|
+
*
|
|
233
|
+
* @param column - Path using "->" syntax.
|
|
234
|
+
* @param value - Match value.
|
|
235
|
+
*/
|
|
236
|
+
whereJson(column: string, value: unknown): this;
|
|
237
|
+
/**
|
|
238
|
+
* Adds an OR WHERE constraint for a nested JSON property.
|
|
239
|
+
*/
|
|
240
|
+
orWhereJson(column: string, value: unknown): this;
|
|
241
|
+
/**
|
|
242
|
+
* Checks if a JSON column contains a specific value.
|
|
243
|
+
*/
|
|
244
|
+
whereJsonContains(column: string, value: unknown): this;
|
|
245
|
+
/**
|
|
246
|
+
* OR version of {@link whereJsonContains}.
|
|
247
|
+
*/
|
|
248
|
+
orWhereJsonContains(column: string, value: unknown): this;
|
|
249
|
+
/**
|
|
250
|
+
* Groups constraints in parentheses.
|
|
251
|
+
*
|
|
252
|
+
* @param callback - Closure for nested builder.
|
|
253
|
+
* @param boolean - Connector (and/or).
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
protected whereNested(callback: (query: QueryBuilderContract<T>) => void, boolean: BooleanOperator): this;
|
|
257
|
+
/**
|
|
258
|
+
* Adds an INNER JOIN.
|
|
259
|
+
*/
|
|
260
|
+
join(table: string, first: string, operator: string, second: string): this;
|
|
261
|
+
/**
|
|
262
|
+
* Adds a LEFT JOIN.
|
|
263
|
+
*/
|
|
264
|
+
leftJoin(table: string, first: string, operator: string, second: string): this;
|
|
265
|
+
/**
|
|
266
|
+
* Adds a RIGHT JOIN.
|
|
267
|
+
*/
|
|
268
|
+
rightJoin(table: string, first: string, operator: string, second: string): this;
|
|
269
|
+
/**
|
|
270
|
+
* Adds a CROSS JOIN.
|
|
271
|
+
*/
|
|
272
|
+
crossJoin(table: string): this;
|
|
273
|
+
/**
|
|
274
|
+
* Internal join registration.
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
protected addJoin(type: JoinType, table: string, first: string, operator: string, second: string): this;
|
|
278
|
+
/**
|
|
279
|
+
* Defines the GROUP BY clause.
|
|
280
|
+
*/
|
|
281
|
+
groupBy(...columns: string[]): this;
|
|
282
|
+
/**
|
|
283
|
+
* Defines a HAVING constraint.
|
|
284
|
+
*/
|
|
285
|
+
having(column: string, operator: Operator, value: unknown): this;
|
|
286
|
+
/**
|
|
287
|
+
* Defines a raw HAVING constraint.
|
|
288
|
+
*/
|
|
289
|
+
havingRaw(sql: string | Expression, bindings?: unknown[]): this;
|
|
290
|
+
/**
|
|
291
|
+
* Defines the ORDER BY clause.
|
|
292
|
+
*/
|
|
293
|
+
orderBy(column: string, direction?: OrderDirection): this;
|
|
294
|
+
/**
|
|
295
|
+
* Helper for DESC ordering.
|
|
296
|
+
*/
|
|
297
|
+
orderByDesc(column: string): this;
|
|
298
|
+
/**
|
|
299
|
+
* Adds a raw SQL ORDER BY clause.
|
|
300
|
+
*/
|
|
301
|
+
orderByRaw(sql: string | Expression, bindings?: unknown[]): this;
|
|
302
|
+
/**
|
|
303
|
+
* Orders results by the latest created_at timestamp.
|
|
304
|
+
*/
|
|
305
|
+
latest(column?: string): this;
|
|
306
|
+
/**
|
|
307
|
+
* Orders results by the oldest created_at timestamp.
|
|
308
|
+
*/
|
|
309
|
+
oldest(column?: string): this;
|
|
310
|
+
/**
|
|
311
|
+
* Constrains the number of results.
|
|
312
|
+
*/
|
|
313
|
+
limit(value: number): this;
|
|
314
|
+
/**
|
|
315
|
+
* Skips the specified number of results.
|
|
316
|
+
*/
|
|
317
|
+
offset(value: number): this;
|
|
318
|
+
/**
|
|
319
|
+
* Alias for {@link offset}.
|
|
320
|
+
*/
|
|
321
|
+
skip(value: number): this;
|
|
322
|
+
/**
|
|
323
|
+
* Alias for {@link limit}.
|
|
324
|
+
*/
|
|
325
|
+
take(value: number): this;
|
|
326
|
+
/**
|
|
327
|
+
* Executes the query using a server-side prepared statement for speed.
|
|
328
|
+
*/
|
|
329
|
+
getPrepared(): Promise<T[]>;
|
|
330
|
+
/**
|
|
331
|
+
* Fetches raw database rows, bypassing the Model hydration layer.
|
|
332
|
+
*
|
|
333
|
+
* @returns Array of plain objects.
|
|
334
|
+
* @internal
|
|
335
|
+
*/
|
|
336
|
+
getRawResults(): Promise<Record<string, unknown>[]>;
|
|
337
|
+
/**
|
|
338
|
+
* Executes the query and returns hydrated records.
|
|
339
|
+
*/
|
|
340
|
+
get(): Promise<T[]>;
|
|
341
|
+
/**
|
|
342
|
+
* Provides an async iterator to stream results one by one.
|
|
343
|
+
*
|
|
344
|
+
* Essential for processing datasets that exceed memory capacity.
|
|
345
|
+
*/
|
|
346
|
+
stream(): AsyncIterable<T>;
|
|
347
|
+
/**
|
|
348
|
+
* Returns the first record matching the query.
|
|
349
|
+
*/
|
|
350
|
+
first(): Promise<T | null>;
|
|
351
|
+
/**
|
|
352
|
+
* Fails if no record matches the query.
|
|
353
|
+
* @throws {RecordNotFoundError}
|
|
354
|
+
*/
|
|
355
|
+
firstOrFail(): Promise<T>;
|
|
356
|
+
/**
|
|
357
|
+
* Shortcut for searching by primary key.
|
|
358
|
+
*/
|
|
359
|
+
find(id: unknown, primaryKey?: string): Promise<T | null>;
|
|
360
|
+
/**
|
|
361
|
+
* Fails if primary key search yields no result.
|
|
362
|
+
*/
|
|
363
|
+
findOrFail(id: unknown, primaryKey?: string): Promise<T>;
|
|
364
|
+
/**
|
|
365
|
+
* Retrieves a single column value from the first matching record.
|
|
366
|
+
*/
|
|
367
|
+
value<V = unknown>(column: string): Promise<V | null>;
|
|
368
|
+
/**
|
|
369
|
+
* Retrieves an array of values for a single column.
|
|
370
|
+
*/
|
|
371
|
+
pluck<V = unknown>(column: string): Promise<V[]>;
|
|
372
|
+
/**
|
|
373
|
+
* Returns true if any records match the query.
|
|
374
|
+
*/
|
|
375
|
+
exists(): Promise<boolean>;
|
|
376
|
+
/**
|
|
377
|
+
* Inverse of {@link exists}.
|
|
378
|
+
*/
|
|
379
|
+
doesntExist(): Promise<boolean>;
|
|
380
|
+
/**
|
|
381
|
+
* Returns the count of matching records.
|
|
382
|
+
*/
|
|
383
|
+
count(column?: string): Promise<number>;
|
|
384
|
+
/**
|
|
385
|
+
* Returns the maximum value of a column.
|
|
386
|
+
*/
|
|
387
|
+
max<V = number>(column: string): Promise<V | null>;
|
|
388
|
+
/**
|
|
389
|
+
* Returns the minimum value of a column.
|
|
390
|
+
*/
|
|
391
|
+
min<V = number>(column: string): Promise<V | null>;
|
|
392
|
+
/**
|
|
393
|
+
* Returns the average value of a column.
|
|
394
|
+
*/
|
|
395
|
+
avg(column: string): Promise<number | null>;
|
|
396
|
+
/**
|
|
397
|
+
* Returns the sum of a column's values.
|
|
398
|
+
*/
|
|
399
|
+
sum(column: string): Promise<number>;
|
|
400
|
+
/**
|
|
401
|
+
* Internal generic aggregate execution.
|
|
402
|
+
* @internal
|
|
403
|
+
*/
|
|
404
|
+
protected aggregate(func: string, column: string): Promise<number | null>;
|
|
405
|
+
/**
|
|
406
|
+
* Inserts data into the table.
|
|
407
|
+
*
|
|
408
|
+
* Automatically handles batching (chunking) to stay within binding limits.
|
|
409
|
+
*
|
|
410
|
+
* @param data - Single object or array of objects.
|
|
411
|
+
* @returns Array of inserted objects (with generated IDs if supported).
|
|
412
|
+
*/
|
|
413
|
+
insert(data: Partial<T> | Partial<T>[]): Promise<T[]>;
|
|
414
|
+
/**
|
|
415
|
+
* Inserts data and returns the primary key.
|
|
416
|
+
*
|
|
417
|
+
* @param data - Record data.
|
|
418
|
+
* @param primaryKey - Name of the auto-increment column.
|
|
419
|
+
* @returns Generated ID.
|
|
420
|
+
* @throws {QueryBuilderError} If ID retrieval fails.
|
|
421
|
+
*/
|
|
422
|
+
insertGetId(data: Partial<T>, primaryKey?: string): Promise<number | bigint>;
|
|
423
|
+
/**
|
|
424
|
+
* Updates records matching the current query state.
|
|
425
|
+
*
|
|
426
|
+
* @param data - Update values.
|
|
427
|
+
* @returns Count of affected rows.
|
|
428
|
+
*/
|
|
429
|
+
update(data: Partial<T>): Promise<number>;
|
|
430
|
+
/**
|
|
431
|
+
* Specialized method for updating JSON fields.
|
|
432
|
+
*/
|
|
433
|
+
updateJson(column: string, value: unknown): Promise<number>;
|
|
434
|
+
/**
|
|
435
|
+
* Deletes records matching the query.
|
|
436
|
+
*
|
|
437
|
+
* Note: This performs a hard delete. For soft deletes, use the Model layer.
|
|
438
|
+
*/
|
|
439
|
+
delete(): Promise<number>;
|
|
440
|
+
/**
|
|
441
|
+
* Drops all records and resets auto-increment state.
|
|
442
|
+
*/
|
|
443
|
+
truncate(): Promise<void>;
|
|
444
|
+
/**
|
|
445
|
+
* Defines relationships to load in bulk after the primary query.
|
|
446
|
+
*/
|
|
447
|
+
with(relation: string | string[] | Record<string, (query: QueryBuilderContract<unknown>) => void>): this;
|
|
448
|
+
/**
|
|
449
|
+
* Filters the query based on relationship existence.
|
|
450
|
+
*/
|
|
451
|
+
whereHas(relation: string, callback?: (query: QueryBuilderContract<unknown>) => void): this;
|
|
452
|
+
/**
|
|
453
|
+
* Retrieves eager load mapping.
|
|
454
|
+
* @internal
|
|
455
|
+
*/
|
|
456
|
+
getEagerLoads(): Map<string, (query: QueryBuilderContract<any>) => void>;
|
|
457
|
+
/**
|
|
458
|
+
* Includes soft-deleted records (where deleted_at is not null).
|
|
459
|
+
*/
|
|
460
|
+
withTrashed(): this;
|
|
461
|
+
/**
|
|
462
|
+
* Excludes non-deleted records.
|
|
463
|
+
*/
|
|
464
|
+
onlyTrashed(): this;
|
|
465
|
+
/**
|
|
466
|
+
* Restores soft-deleted records to active state.
|
|
467
|
+
*/
|
|
468
|
+
restore(): Promise<number>;
|
|
469
|
+
/**
|
|
470
|
+
* Bypasses soft deletes to permanently remove records.
|
|
471
|
+
*/
|
|
472
|
+
forceDelete(): Promise<number>;
|
|
473
|
+
/**
|
|
474
|
+
* Atomically increments a numeric column.
|
|
475
|
+
*/
|
|
476
|
+
increment(column: string, amount?: number, extra?: Partial<T>): Promise<number>;
|
|
477
|
+
/**
|
|
478
|
+
* Atomically decrements a numeric column.
|
|
479
|
+
*/
|
|
480
|
+
decrement(column: string, amount?: number, extra?: Partial<T>): Promise<number>;
|
|
481
|
+
/**
|
|
482
|
+
* Inserts records or updates them if a uniqueness conflict occurs.
|
|
483
|
+
*
|
|
484
|
+
* @param data - Records to process.
|
|
485
|
+
* @param uniqueBy - Column(s) that identify uniqueness.
|
|
486
|
+
* @param update - Column(s) to update on conflict.
|
|
487
|
+
* @returns Affected rows.
|
|
488
|
+
*/
|
|
489
|
+
upsert(data: Partial<T> | Partial<T>[], uniqueBy: string | string[], update?: string[]): Promise<number>;
|
|
490
|
+
/**
|
|
491
|
+
* Alias for {@link paginate}.
|
|
492
|
+
*/
|
|
493
|
+
simplePaginate(perPage?: number, page?: number, primaryKey?: string): Promise<PaginateResult<T>>;
|
|
494
|
+
/**
|
|
495
|
+
* Processes the entire dataset in memory-efficient chunks.
|
|
496
|
+
*
|
|
497
|
+
* @param size - Chunk size.
|
|
498
|
+
* @param callback - Logic for each chunk.
|
|
499
|
+
*/
|
|
500
|
+
chunk(size: number, callback: (results: T[]) => Promise<undefined | boolean>): Promise<void>;
|
|
501
|
+
/**
|
|
502
|
+
* Returns a paginated result set with metadata.
|
|
503
|
+
*/
|
|
504
|
+
paginate(perPage?: number, page?: number, primaryKey?: string): Promise<PaginateResult<T>>;
|
|
505
|
+
/**
|
|
506
|
+
* Force an ID sort if none exists to prevent skipping records during pagination.
|
|
507
|
+
*/
|
|
508
|
+
ensureDeterministicOrder(primaryKey?: string): this;
|
|
509
|
+
/**
|
|
510
|
+
* Sets the read-only flag for this query.
|
|
511
|
+
*/
|
|
512
|
+
readonly(value?: boolean): this;
|
|
513
|
+
/**
|
|
514
|
+
* Checks if read-only is active.
|
|
515
|
+
* @internal
|
|
516
|
+
*/
|
|
517
|
+
getIsReadOnly(): boolean;
|
|
518
|
+
/**
|
|
519
|
+
* Creates a deep copy of the current builder.
|
|
520
|
+
*
|
|
521
|
+
* Leverages copy-on-write; state is initially shared.
|
|
522
|
+
*/
|
|
523
|
+
clone(): QueryBuilderContract<T>;
|
|
524
|
+
/**
|
|
525
|
+
* Returns a finalized query structure ready for compilation.
|
|
526
|
+
*
|
|
527
|
+
* Includes global scope application.
|
|
528
|
+
*/
|
|
529
|
+
getCompiledQuery(): CompiledQuery;
|
|
530
|
+
/**
|
|
531
|
+
* Internal query structural assembly.
|
|
532
|
+
* @internal
|
|
533
|
+
*/
|
|
534
|
+
protected getRawCompiledQuery(): CompiledQuery;
|
|
535
|
+
/**
|
|
536
|
+
* Executes all registered global scope callbacks.
|
|
537
|
+
* @internal
|
|
538
|
+
*/
|
|
539
|
+
protected applyGlobalScopes(): void;
|
|
540
|
+
/**
|
|
541
|
+
* Returns all bound values for the current state.
|
|
542
|
+
*/
|
|
543
|
+
getBindings(): unknown[];
|
|
544
|
+
/**
|
|
545
|
+
* Checks for LIMIT or OFFSET definitions.
|
|
546
|
+
*/
|
|
547
|
+
hasLimitOrOffset(): boolean;
|
|
548
|
+
/**
|
|
549
|
+
* Returns the compiled SQL string.
|
|
550
|
+
*/
|
|
551
|
+
toSql(): string;
|
|
552
|
+
/**
|
|
553
|
+
* Logs SQL and Bindings to standard output.
|
|
554
|
+
*/
|
|
555
|
+
dump(): this;
|
|
556
|
+
/**
|
|
557
|
+
* Logs and exits process.
|
|
558
|
+
*/
|
|
559
|
+
dd(): never;
|
|
560
|
+
/**
|
|
561
|
+
* Registers a permanent filter for this builder instance.
|
|
562
|
+
*/
|
|
563
|
+
applyScope(name: string, callback: (query: QueryBuilderContract<T>) => void): this;
|
|
564
|
+
/**
|
|
565
|
+
* Bypasses a previously registered scope.
|
|
566
|
+
*/
|
|
567
|
+
withoutGlobalScope(name: string): this;
|
|
568
|
+
/**
|
|
569
|
+
* Optimizes chunk size to prevent too many bindings for the driver.
|
|
570
|
+
* @internal
|
|
571
|
+
*/
|
|
572
|
+
private calculateOptimalChunkSize;
|
|
573
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group By Clause
|
|
3
|
+
*
|
|
4
|
+
* Handles GROUP BY operations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Group By Clause
|
|
8
|
+
* @description Handles the construction of GROUP BY clauses for SQL queries
|
|
9
|
+
*/
|
|
10
|
+
export declare class GroupByClause {
|
|
11
|
+
/** Array of columns to group by */
|
|
12
|
+
private groups;
|
|
13
|
+
/**
|
|
14
|
+
* Add GROUP BY columns to the query
|
|
15
|
+
*
|
|
16
|
+
* @param columns - List of column names
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* clause.groupBy('category', 'status')
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
groupBy(...columns: string[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get all group by columns
|
|
25
|
+
*
|
|
26
|
+
* @returns Array of column names
|
|
27
|
+
*/
|
|
28
|
+
getGroups(): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Compile the GROUP BY clause to SQL
|
|
31
|
+
*
|
|
32
|
+
* @returns GROUP BY clause SQL string
|
|
33
|
+
*/
|
|
34
|
+
toSQL(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Reset the clause state
|
|
37
|
+
*/
|
|
38
|
+
reset(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the clause has any groups
|
|
41
|
+
*
|
|
42
|
+
* @returns True if groups exist
|
|
43
|
+
*/
|
|
44
|
+
hasGroups(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Clone the clause
|
|
47
|
+
*
|
|
48
|
+
* @returns A deep copy of the clause
|
|
49
|
+
*/
|
|
50
|
+
clone(): GroupByClause;
|
|
51
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Having Clause
|
|
3
|
+
*
|
|
4
|
+
* Handles HAVING operations
|
|
5
|
+
*/
|
|
6
|
+
import type { HavingClause as HavingClauseType, Operator } from '../../types';
|
|
7
|
+
import { Expression } from '../Expression';
|
|
8
|
+
/**
|
|
9
|
+
* Having Clause
|
|
10
|
+
* @description Handles the construction of HAVING clauses for SQL queries
|
|
11
|
+
*/
|
|
12
|
+
export declare class HavingClause {
|
|
13
|
+
/** Internal storage for having clauses */
|
|
14
|
+
private havings;
|
|
15
|
+
/** Bindings for having clauses */
|
|
16
|
+
private bindings;
|
|
17
|
+
/**
|
|
18
|
+
* Add a HAVING clause to the query
|
|
19
|
+
*
|
|
20
|
+
* @param column - Column name
|
|
21
|
+
* @param operator - Comparison operator
|
|
22
|
+
* @param value - Value to compare against
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* clause.having('count(*)', '>', 10)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
having(column: string, operator: Operator, value: unknown): void;
|
|
29
|
+
/**
|
|
30
|
+
* Add a raw HAVING clause to the query
|
|
31
|
+
*
|
|
32
|
+
* @param sql - Raw SQL string or Expression instance
|
|
33
|
+
* @param bindings - Optional array of bindings
|
|
34
|
+
*/
|
|
35
|
+
havingRaw(sql: string | Expression, bindings?: unknown[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get all having clauses
|
|
38
|
+
*
|
|
39
|
+
* @returns Array of having clauses
|
|
40
|
+
*/
|
|
41
|
+
getHavings(): HavingClauseType[];
|
|
42
|
+
/**
|
|
43
|
+
* Get the bindings associated with this clause
|
|
44
|
+
*
|
|
45
|
+
* @returns Array of bindings
|
|
46
|
+
*/
|
|
47
|
+
getBindings(): unknown[];
|
|
48
|
+
/**
|
|
49
|
+
* Compile the HAVING clause to SQL
|
|
50
|
+
*
|
|
51
|
+
* @returns HAVING clause SQL string
|
|
52
|
+
*/
|
|
53
|
+
toSQL(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Reset the clause state
|
|
56
|
+
*/
|
|
57
|
+
reset(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Check if the clause has any having conditions
|
|
60
|
+
*
|
|
61
|
+
* @returns True if having conditions exist
|
|
62
|
+
*/
|
|
63
|
+
hasHavings(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Clone the clause
|
|
66
|
+
*
|
|
67
|
+
* @returns A deep copy of the clause
|
|
68
|
+
*/
|
|
69
|
+
clone(): HavingClause;
|
|
70
|
+
}
|