@bunnykit/orm 0.1.11 → 0.1.13
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 +10 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/model/Model.d.ts +49 -33
- package/dist/src/model/Observer.d.ts +2 -2
- package/dist/src/query/Builder.d.ts +71 -67
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1262,7 +1262,16 @@ export class User extends Model {
|
|
|
1262
1262
|
}
|
|
1263
1263
|
```
|
|
1264
1264
|
|
|
1265
|
-
Editors that include the generated `.d.ts` files in `tsconfig.json` will understand `user.name`, `user.email`, etc. The generated
|
|
1265
|
+
Editors that include the generated `.d.ts` files in `tsconfig.json` will understand `user.name`, `user.email`, etc. The same generated attributes are also used for column-name autocomplete in model and builder APIs:
|
|
1266
|
+
|
|
1267
|
+
```ts
|
|
1268
|
+
await User.where("email", "alice@example.com").first();
|
|
1269
|
+
await User.where({ email: "alice@example.com" }).first();
|
|
1270
|
+
await User.orderBy("created_at").get();
|
|
1271
|
+
await User.create({ id: 1, name: "Alice", email: "alice@example.com" });
|
|
1272
|
+
```
|
|
1273
|
+
|
|
1274
|
+
Column arguments still accept raw strings for joins, aliases, expressions, and advanced SQL, so autocomplete is helpful without blocking escape hatches. The generated files can be safely **gitignored** and regenerated whenever your schema changes.
|
|
1266
1275
|
|
|
1267
1276
|
If you still want generated base classes, use the programmatic generator with `{ stubs: true }`.
|
|
1268
1277
|
|
package/dist/src/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { MySqlGrammar } from "./schema/grammars/MySqlGrammar.js";
|
|
|
14
14
|
export { PostgresGrammar } from "./schema/grammars/PostgresGrammar.js";
|
|
15
15
|
export { Builder } from "./query/Builder.js";
|
|
16
16
|
export { Model, HasMany, BelongsTo, HasOne, HasManyThrough, HasOneThrough } from "./model/Model.js";
|
|
17
|
-
export type { ModelConstructor, GlobalScope, CastDefinition, CastsAttributes } from "./model/Model.js";
|
|
17
|
+
export type { ModelAttributeInput, ModelAttributes, ModelColumn, ModelColumnValue, ModelConstructor, GlobalScope, CastDefinition, CastsAttributes, } from "./model/Model.js";
|
|
18
18
|
export { ModelNotFoundError } from "./model/ModelNotFoundError.js";
|
|
19
19
|
export { ObserverRegistry, type ObserverContract } from "./model/Observer.js";
|
|
20
20
|
export { MorphMap } from "./model/MorphMap.js";
|
|
@@ -4,6 +4,15 @@ import { MorphTo, MorphOne, MorphMany, MorphToMany } from "./MorphRelations.js";
|
|
|
4
4
|
import { BelongsToMany } from "./BelongsToMany.js";
|
|
5
5
|
export type ModelConstructor<T extends Model = Model> = (new (...args: any[]) => T) & Omit<typeof Model, "prototype">;
|
|
6
6
|
export type GlobalScope = (builder: Builder<any>, model: ModelConstructor) => void;
|
|
7
|
+
export type LiteralUnion<T extends string> = T | (string & {});
|
|
8
|
+
type BaseModelInstanceKey = "$attributes" | "$original" | "$exists" | "$relations" | "$casts" | "$connection" | "fill" | "setConnection" | "getConnection" | "isFillable" | "getAttribute" | "setAttribute" | "castAttribute" | "serializeCastAttribute" | "mergeCasts" | "getDirty" | "isDirty" | "save" | "updateTimestamps" | "touch" | "increment" | "decrement" | "load" | "delete" | "restore" | "forceDelete" | "refresh" | "toJSON" | "toString" | "freshTimestamp" | "setRelation" | "getRelation" | "hasMany" | "belongsTo" | "hasOne" | "hasManyThrough" | "hasOneThrough" | "belongsToMany" | "morphTo" | "morphOne" | "morphMany" | "morphToMany" | "morphedByMany";
|
|
9
|
+
export type ModelInstanceAttributeKeys<T> = Extract<Exclude<keyof T, BaseModelInstanceKey>, string>;
|
|
10
|
+
export type ModelAttributes<T> = T extends {
|
|
11
|
+
$attributes: Record<string, any>;
|
|
12
|
+
} ? string extends keyof T["$attributes"] ? Pick<T, ModelInstanceAttributeKeys<T>> : T["$attributes"] : T;
|
|
13
|
+
export type ModelColumn<T> = LiteralUnion<Extract<keyof ModelAttributes<T>, string>>;
|
|
14
|
+
export type ModelColumnValue<T, K> = K extends keyof ModelAttributes<T> ? ModelAttributes<T>[K] : any;
|
|
15
|
+
export type ModelAttributeInput<T> = Partial<ModelAttributes<T>> & Record<string, any>;
|
|
7
16
|
export type CastDefinition = string | CastsAttributes | (new (...args: any[]) => CastsAttributes);
|
|
8
17
|
export interface CastsAttributes {
|
|
9
18
|
get(model: Model, key: string, value: any, attributes: Record<string, any>): any;
|
|
@@ -110,36 +119,42 @@ export declare class Model<T extends Record<string, any> = Record<string, any>>
|
|
|
110
119
|
static applyGlobalScopes(builder: Builder<any>): void;
|
|
111
120
|
static getQualifiedDeletedAtColumn(): string;
|
|
112
121
|
static shouldAutoGeneratePrimaryKey(): Promise<boolean>;
|
|
113
|
-
static create<M extends ModelConstructor>(this: M, attributes:
|
|
122
|
+
static create<M extends ModelConstructor>(this: M, attributes: ModelAttributeInput<InstanceType<M>>): Promise<InstanceType<M>>;
|
|
114
123
|
static find<M extends ModelConstructor>(this: M, id: any): Promise<InstanceType<M> | null>;
|
|
115
124
|
static findOrFail<M extends ModelConstructor>(this: M, id: any): Promise<InstanceType<M>>;
|
|
116
125
|
static first<M extends ModelConstructor>(this: M): Promise<InstanceType<M> | null>;
|
|
117
126
|
static firstOrFail<M extends ModelConstructor>(this: M): Promise<InstanceType<M>>;
|
|
118
|
-
static firstOrCreate<M extends ModelConstructor>(this: M, attributes?:
|
|
119
|
-
static updateOrCreate<M extends ModelConstructor>(this: M, attributes:
|
|
120
|
-
static where<M extends ModelConstructor>(this: M, column:
|
|
121
|
-
static
|
|
122
|
-
static
|
|
123
|
-
static
|
|
124
|
-
static
|
|
125
|
-
static
|
|
126
|
-
static
|
|
127
|
-
static
|
|
128
|
-
static
|
|
129
|
-
static
|
|
130
|
-
static
|
|
131
|
-
static
|
|
132
|
-
static
|
|
133
|
-
static
|
|
134
|
-
static
|
|
135
|
-
static
|
|
136
|
-
static
|
|
137
|
-
static
|
|
138
|
-
static
|
|
139
|
-
static
|
|
140
|
-
static
|
|
141
|
-
static
|
|
142
|
-
static
|
|
127
|
+
static firstOrCreate<M extends ModelConstructor>(this: M, attributes?: ModelAttributeInput<InstanceType<M>>, values?: ModelAttributeInput<InstanceType<M>>): Promise<InstanceType<M>>;
|
|
128
|
+
static updateOrCreate<M extends ModelConstructor>(this: M, attributes: ModelAttributeInput<InstanceType<M>>, values?: ModelAttributeInput<InstanceType<M>>): Promise<InstanceType<M>>;
|
|
129
|
+
static where<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, value: any): Builder<InstanceType<M>>;
|
|
130
|
+
static where<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator: string, value: any): Builder<InstanceType<M>>;
|
|
131
|
+
static where<M extends ModelConstructor>(this: M, column: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
132
|
+
static where<M extends ModelConstructor>(this: M, column: ModelAttributeInput<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
133
|
+
static orderBy<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, direction?: "asc" | "desc"): Builder<InstanceType<M>>;
|
|
134
|
+
static whereIn<M extends ModelConstructor, K extends ModelColumn<InstanceType<M>>>(this: M, column: K, values: ModelColumnValue<InstanceType<M>, K>[]): Builder<InstanceType<M>>;
|
|
135
|
+
static whereNull<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
136
|
+
static whereNotNull<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
137
|
+
static orWhere<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, value: any): Builder<InstanceType<M>>;
|
|
138
|
+
static orWhere<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator: string, value: any): Builder<InstanceType<M>>;
|
|
139
|
+
static orWhere<M extends ModelConstructor>(this: M, column: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
140
|
+
static orWhere<M extends ModelConstructor>(this: M, column: ModelAttributeInput<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
141
|
+
static whereNot<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>> | ModelAttributeInput<InstanceType<M>>, value?: any): Builder<InstanceType<M>>;
|
|
142
|
+
static orWhereNot<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>> | ModelAttributeInput<InstanceType<M>>, value?: any): Builder<InstanceType<M>>;
|
|
143
|
+
static whereDate<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
144
|
+
static orWhereDate<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
145
|
+
static whereDay<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
146
|
+
static orWhereDay<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
147
|
+
static whereMonth<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
148
|
+
static orWhereMonth<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
149
|
+
static whereYear<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
150
|
+
static orWhereYear<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
151
|
+
static whereTime<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
152
|
+
static orWhereTime<M extends ModelConstructor>(this: M, column: ModelColumn<InstanceType<M>>, operator?: string | any, value?: any): Builder<InstanceType<M>>;
|
|
153
|
+
static latest<M extends ModelConstructor>(this: M, column?: ModelColumn<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
154
|
+
static oldest<M extends ModelConstructor>(this: M, column?: ModelColumn<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
155
|
+
static when<M extends ModelConstructor>(this: M, condition: any, callback: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>, defaultCallback?: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
156
|
+
static unless<M extends ModelConstructor>(this: M, condition: any, callback: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>, defaultCallback?: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
157
|
+
static tap<M extends ModelConstructor>(this: M, callback: (query: Builder<InstanceType<M>>) => void | Builder<InstanceType<M>>): Builder<InstanceType<M>>;
|
|
143
158
|
static take<M extends ModelConstructor>(this: M, count: number): Builder<InstanceType<M>>;
|
|
144
159
|
static skip<M extends ModelConstructor>(this: M, count: number): Builder<InstanceType<M>>;
|
|
145
160
|
static inRandomOrder<M extends ModelConstructor>(this: M): Builder<InstanceType<M>>;
|
|
@@ -155,10 +170,10 @@ export declare class Model<T extends Record<string, any> = Record<string, any>>
|
|
|
155
170
|
static whereHas<M extends ModelConstructor>(this: M, relationName: string, callback?: (query: Builder<any>) => void | Builder<any>, operator?: string, count?: number): Builder<InstanceType<M>>;
|
|
156
171
|
static doesntHave<M extends ModelConstructor>(this: M, relationName: string): Builder<InstanceType<M>>;
|
|
157
172
|
static withCount<M extends ModelConstructor>(this: M, relationName: string, alias?: string): Builder<InstanceType<M>>;
|
|
158
|
-
static withSum<M extends ModelConstructor>(this: M, relationName: string, column:
|
|
159
|
-
static withAvg<M extends ModelConstructor>(this: M, relationName: string, column:
|
|
160
|
-
static withMin<M extends ModelConstructor>(this: M, relationName: string, column:
|
|
161
|
-
static withMax<M extends ModelConstructor>(this: M, relationName: string, column:
|
|
173
|
+
static withSum<M extends ModelConstructor>(this: M, relationName: string, column: ModelColumn<InstanceType<M>>, alias?: string): Builder<InstanceType<M>>;
|
|
174
|
+
static withAvg<M extends ModelConstructor>(this: M, relationName: string, column: ModelColumn<InstanceType<M>>, alias?: string): Builder<InstanceType<M>>;
|
|
175
|
+
static withMin<M extends ModelConstructor>(this: M, relationName: string, column: ModelColumn<InstanceType<M>>, alias?: string): Builder<InstanceType<M>>;
|
|
176
|
+
static withMax<M extends ModelConstructor>(this: M, relationName: string, column: ModelColumn<InstanceType<M>>, alias?: string): Builder<InstanceType<M>>;
|
|
162
177
|
static all<M extends ModelConstructor>(this: M): Promise<InstanceType<M>[]>;
|
|
163
178
|
static paginate<M extends ModelConstructor>(this: M, perPage?: number, page?: number): Promise<import("../query/Builder.js").Paginator<InstanceType<M>>>;
|
|
164
179
|
static chunk<M extends ModelConstructor>(this: M, count: number, callback: (items: InstanceType<M>[]) => void | Promise<void>): Promise<void>;
|
|
@@ -167,7 +182,7 @@ export declare class Model<T extends Record<string, any> = Record<string, any>>
|
|
|
167
182
|
static lazy<M extends ModelConstructor>(this: M, count?: number): AsyncGenerator<InstanceType<M>>;
|
|
168
183
|
static eagerLoadRelations(models: Model[], relations: string[]): Promise<void>;
|
|
169
184
|
static eagerLoadRelation(models: Model[], relationName: string): Promise<void>;
|
|
170
|
-
fill(attributes: Partial<T>): this;
|
|
185
|
+
fill(attributes: Partial<T> | ModelAttributeInput<this>): this;
|
|
171
186
|
setConnection(connection: Connection): this;
|
|
172
187
|
getConnection(): Connection;
|
|
173
188
|
isFillable(key: string): boolean;
|
|
@@ -185,8 +200,8 @@ export declare class Model<T extends Record<string, any> = Record<string, any>>
|
|
|
185
200
|
save(): Promise<this>;
|
|
186
201
|
updateTimestamps(): void;
|
|
187
202
|
touch(): Promise<boolean>;
|
|
188
|
-
increment(column:
|
|
189
|
-
decrement(column:
|
|
203
|
+
increment<K extends ModelColumn<this>>(column: K, amount?: number, extra?: ModelAttributeInput<this>): Promise<this>;
|
|
204
|
+
decrement<K extends ModelColumn<this>>(column: K, amount?: number, extra?: ModelAttributeInput<this>): Promise<this>;
|
|
190
205
|
load(...relations: string[]): Promise<this>;
|
|
191
206
|
delete(): Promise<boolean>;
|
|
192
207
|
restore(): Promise<boolean>;
|
|
@@ -209,3 +224,4 @@ export declare class Model<T extends Record<string, any> = Record<string, any>>
|
|
|
209
224
|
morphToMany<R extends Model>(related: ModelConstructor<R>, name: string, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string): MorphToMany<R>;
|
|
210
225
|
morphedByMany<R extends Model>(related: ModelConstructor<R>, name: string, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string): MorphToMany<R>;
|
|
211
226
|
}
|
|
227
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Model } from "./Model.js";
|
|
2
|
-
export interface ObserverContract<T extends Model = Model
|
|
2
|
+
export interface ObserverContract<T extends Model<any> = Model<any>> {
|
|
3
3
|
creating?(model: T): Promise<void> | void;
|
|
4
4
|
created?(model: T): Promise<void> | void;
|
|
5
5
|
updating?(model: T): Promise<void> | void;
|
|
@@ -15,5 +15,5 @@ export declare class ObserverRegistry {
|
|
|
15
15
|
private static observers;
|
|
16
16
|
static register(modelClass: typeof Model, observer: ObserverContract): void;
|
|
17
17
|
static get(modelClass: typeof Model): ObserverContract[];
|
|
18
|
-
static dispatch<T extends Model
|
|
18
|
+
static dispatch<T extends Model<any>>(event: keyof ObserverContract, model: T): Promise<void>;
|
|
19
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection } from "../connection/Connection.js";
|
|
2
2
|
import type { WhereClause, OrderClause, HavingClause, UnionClause } from "../types/index.js";
|
|
3
|
-
import type { ModelConstructor } from "../model/Model.js";
|
|
3
|
+
import type { ModelAttributeInput, ModelColumn, ModelColumnValue, ModelConstructor } from "../model/Model.js";
|
|
4
4
|
type RelationConstraint = (query: Builder<any>) => void | Builder<any>;
|
|
5
5
|
export interface Paginator<T> {
|
|
6
6
|
data: T[];
|
|
@@ -34,59 +34,63 @@ export declare class Builder<T = Record<string, any>> {
|
|
|
34
34
|
private get grammar();
|
|
35
35
|
setModel(model: ModelConstructor): this;
|
|
36
36
|
table(table: string): this;
|
|
37
|
-
select(...columns:
|
|
37
|
+
select(...columns: ModelColumn<T>[]): this;
|
|
38
38
|
distinct(): this;
|
|
39
|
-
where(column:
|
|
39
|
+
where(column: ModelColumn<T>, value: any): this;
|
|
40
|
+
where(column: ModelColumn<T>, operator: string, value: any, boolean?: "and" | "or", scope?: string): this;
|
|
41
|
+
where(column: ModelAttributeInput<T> | ((query: Builder<T>) => void), operator?: string | any, value?: any, boolean?: "and" | "or", scope?: string): this;
|
|
40
42
|
private whereNested;
|
|
41
|
-
orWhere(column:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
orWhere(column: ModelColumn<T>, value: any): this;
|
|
44
|
+
orWhere(column: ModelColumn<T>, operator: string, value: any): this;
|
|
45
|
+
orWhere(column: ModelAttributeInput<T> | ((query: Builder<T>) => void), operator?: string | any, value?: any): this;
|
|
46
|
+
whereNot(column: ModelColumn<T> | ModelAttributeInput<T>, value?: any, boolean?: "and" | "or"): this;
|
|
47
|
+
orWhereNot(column: ModelColumn<T> | ModelAttributeInput<T>, value?: any): this;
|
|
48
|
+
whereIn<K extends ModelColumn<T>>(column: K, values: ModelColumnValue<T, K>[], boolean?: "and" | "or", scope?: string): this;
|
|
49
|
+
whereNotIn<K extends ModelColumn<T>>(column: K, values: ModelColumnValue<T, K>[], boolean?: "and" | "or", scope?: string): this;
|
|
50
|
+
whereNull(column: ModelColumn<T>, boolean?: "and" | "or", scope?: string): this;
|
|
51
|
+
whereNotNull(column: ModelColumn<T>, boolean?: "and" | "or", scope?: string): this;
|
|
52
|
+
whereBetween<K extends ModelColumn<T>>(column: K, values: [ModelColumnValue<T, K>, ModelColumnValue<T, K>], boolean?: "and" | "or", scope?: string): this;
|
|
53
|
+
whereNotBetween<K extends ModelColumn<T>>(column: K, values: [ModelColumnValue<T, K>, ModelColumnValue<T, K>], boolean?: "and" | "or", scope?: string): this;
|
|
54
|
+
whereDate(column: ModelColumn<T>, operator?: string | any, value?: any, boolean?: "and" | "or"): this;
|
|
55
|
+
orWhereDate(column: ModelColumn<T>, operator?: string | any, value?: any): this;
|
|
56
|
+
whereDay(column: ModelColumn<T>, operator?: string | any, value?: any, boolean?: "and" | "or"): this;
|
|
57
|
+
orWhereDay(column: ModelColumn<T>, operator?: string | any, value?: any): this;
|
|
58
|
+
whereMonth(column: ModelColumn<T>, operator?: string | any, value?: any, boolean?: "and" | "or"): this;
|
|
59
|
+
orWhereMonth(column: ModelColumn<T>, operator?: string | any, value?: any): this;
|
|
60
|
+
whereYear(column: ModelColumn<T>, operator?: string | any, value?: any, boolean?: "and" | "or"): this;
|
|
61
|
+
orWhereYear(column: ModelColumn<T>, operator?: string | any, value?: any): this;
|
|
62
|
+
whereTime(column: ModelColumn<T>, operator?: string | any, value?: any, boolean?: "and" | "or"): this;
|
|
63
|
+
orWhereTime(column: ModelColumn<T>, operator?: string | any, value?: any): this;
|
|
60
64
|
whereRaw(sql: string, boolean?: "and" | "or", scope?: string): this;
|
|
61
65
|
whereColumn(first: string, operator: string, second: string, boolean?: "and" | "or"): this;
|
|
62
66
|
whereExists(sql: string, boolean?: "and" | "or", not?: boolean): this;
|
|
63
|
-
orWhereNull(column:
|
|
64
|
-
orWhereNotNull(column:
|
|
65
|
-
orWhereBetween(column:
|
|
66
|
-
orWhereNotBetween(column:
|
|
67
|
-
orWhereIn(column:
|
|
68
|
-
orWhereNotIn(column:
|
|
67
|
+
orWhereNull(column: ModelColumn<T>, scope?: string): this;
|
|
68
|
+
orWhereNotNull(column: ModelColumn<T>, scope?: string): this;
|
|
69
|
+
orWhereBetween<K extends ModelColumn<T>>(column: K, values: [ModelColumnValue<T, K>, ModelColumnValue<T, K>], scope?: string): this;
|
|
70
|
+
orWhereNotBetween<K extends ModelColumn<T>>(column: K, values: [ModelColumnValue<T, K>, ModelColumnValue<T, K>], scope?: string): this;
|
|
71
|
+
orWhereIn<K extends ModelColumn<T>>(column: K, values: ModelColumnValue<T, K>[], scope?: string): this;
|
|
72
|
+
orWhereNotIn<K extends ModelColumn<T>>(column: K, values: ModelColumnValue<T, K>[], scope?: string): this;
|
|
69
73
|
orWhereExists(sql: string): this;
|
|
70
74
|
orWhereNotExists(sql: string): this;
|
|
71
75
|
orWhereColumn(first: string, operator: string, second: string): this;
|
|
72
76
|
orWhereRaw(sql: string, scope?: string): this;
|
|
73
|
-
whereJsonContains(column:
|
|
74
|
-
whereJsonLength(column:
|
|
75
|
-
whereLike(column:
|
|
76
|
-
whereNotLike(column:
|
|
77
|
-
whereRegexp(column:
|
|
78
|
-
whereFullText(columns:
|
|
79
|
-
whereAll(columns:
|
|
80
|
-
whereAny(columns:
|
|
81
|
-
orderBy(column:
|
|
82
|
-
latest(column?:
|
|
83
|
-
oldest(column?:
|
|
77
|
+
whereJsonContains(column: ModelColumn<T>, value: any, boolean?: "and" | "or", not?: boolean): this;
|
|
78
|
+
whereJsonLength(column: ModelColumn<T>, operator?: string | number, value?: number, boolean?: "and" | "or", not?: boolean): this;
|
|
79
|
+
whereLike(column: ModelColumn<T>, value: string, boolean?: "and" | "or", not?: boolean): this;
|
|
80
|
+
whereNotLike(column: ModelColumn<T>, value: string): this;
|
|
81
|
+
whereRegexp(column: ModelColumn<T>, value: string, boolean?: "and" | "or", not?: boolean): this;
|
|
82
|
+
whereFullText(columns: ModelColumn<T> | ModelColumn<T>[], value: string, boolean?: "and" | "or", not?: boolean): this;
|
|
83
|
+
whereAll(columns: ModelColumn<T>[], operator: string, value: any, boolean?: "and" | "or"): this;
|
|
84
|
+
whereAny(columns: ModelColumn<T>[], operator: string, value: any, boolean?: "and" | "or"): this;
|
|
85
|
+
orderBy(column: ModelColumn<T>, direction?: "asc" | "desc"): this;
|
|
86
|
+
latest(column?: ModelColumn<T>): this;
|
|
87
|
+
oldest(column?: ModelColumn<T>): this;
|
|
84
88
|
inRandomOrder(): this;
|
|
85
|
-
orderByDesc(column:
|
|
86
|
-
reorder(column?:
|
|
87
|
-
groupBy(...columns:
|
|
88
|
-
having(column:
|
|
89
|
-
orHaving(column:
|
|
89
|
+
orderByDesc(column: ModelColumn<T>): this;
|
|
90
|
+
reorder(column?: ModelColumn<T>, direction?: "asc" | "desc"): this;
|
|
91
|
+
groupBy(...columns: ModelColumn<T>[]): this;
|
|
92
|
+
having(column: ModelColumn<T>, operator: string, value: any): this;
|
|
93
|
+
orHaving(column: ModelColumn<T>, operator: string, value: any): this;
|
|
90
94
|
havingRaw(sql: string, boolean?: "and" | "or"): this;
|
|
91
95
|
orHavingRaw(sql: string): this;
|
|
92
96
|
limit(count: number): this;
|
|
@@ -114,11 +118,11 @@ export declare class Builder<T = Record<string, any>> {
|
|
|
114
118
|
doesntHave(relationName: string, callback?: RelationConstraint): this;
|
|
115
119
|
whereDoesntHave(relationName: string, callback?: RelationConstraint): this;
|
|
116
120
|
withCount(relationName: string, alias?: string): this;
|
|
117
|
-
withSum(relationName: string, column:
|
|
118
|
-
withAvg(relationName: string, column:
|
|
119
|
-
withMin(relationName: string, column:
|
|
120
|
-
withMax(relationName: string, column:
|
|
121
|
-
addSelect(...columns:
|
|
121
|
+
withSum(relationName: string, column: ModelColumn<T>, alias?: string): this;
|
|
122
|
+
withAvg(relationName: string, column: ModelColumn<T>, alias?: string): this;
|
|
123
|
+
withMin(relationName: string, column: ModelColumn<T>, alias?: string): this;
|
|
124
|
+
withMax(relationName: string, column: ModelColumn<T>, alias?: string): this;
|
|
125
|
+
addSelect(...columns: ModelColumn<T>[]): this;
|
|
122
126
|
selectRaw(sql: string): this;
|
|
123
127
|
fromSub(query: Builder<any> | string, as: string): this;
|
|
124
128
|
updateFrom(table: string, first: string, operator: string, second: string): this;
|
|
@@ -138,36 +142,36 @@ export declare class Builder<T = Record<string, any>> {
|
|
|
138
142
|
toSql(): string;
|
|
139
143
|
get(): Promise<T[]>;
|
|
140
144
|
first(): Promise<T | null>;
|
|
141
|
-
find(id: any, column?:
|
|
142
|
-
findOrFail(id: any, column?:
|
|
145
|
+
find(id: any, column?: ModelColumn<T>): Promise<T | null>;
|
|
146
|
+
findOrFail(id: any, column?: ModelColumn<T>): Promise<T>;
|
|
143
147
|
firstOrFail(): Promise<T>;
|
|
144
|
-
firstOrCreate(attributes?:
|
|
145
|
-
updateOrCreate(attributes:
|
|
146
|
-
pluck(column:
|
|
148
|
+
firstOrCreate(attributes?: ModelAttributeInput<T>, values?: ModelAttributeInput<T>): Promise<T>;
|
|
149
|
+
updateOrCreate(attributes: ModelAttributeInput<T>, values?: ModelAttributeInput<T>): Promise<T>;
|
|
150
|
+
pluck<K extends ModelColumn<T>>(column: K): Promise<ModelColumnValue<T, K>[]>;
|
|
147
151
|
private aggregate;
|
|
148
|
-
count(column?:
|
|
149
|
-
sum(column:
|
|
150
|
-
avg(column:
|
|
151
|
-
min(column:
|
|
152
|
-
max(column:
|
|
152
|
+
count(column?: ModelColumn<T> | "*"): Promise<number>;
|
|
153
|
+
sum(column: ModelColumn<T>): Promise<number>;
|
|
154
|
+
avg(column: ModelColumn<T>): Promise<number>;
|
|
155
|
+
min<K extends ModelColumn<T>>(column: K): Promise<ModelColumnValue<T, K> | null>;
|
|
156
|
+
max<K extends ModelColumn<T>>(column: K): Promise<ModelColumnValue<T, K> | null>;
|
|
153
157
|
paginate(perPage?: number, page?: number): Promise<Paginator<T>>;
|
|
154
158
|
chunk(count: number, callback: (items: T[]) => void | Promise<void>): Promise<void>;
|
|
155
159
|
each(count: number, callback: (item: T) => void | Promise<void>): Promise<void>;
|
|
156
160
|
cursor(): AsyncGenerator<T>;
|
|
157
161
|
lazy(count?: number): AsyncGenerator<T>;
|
|
158
|
-
insert(data:
|
|
159
|
-
insertGetId(data:
|
|
160
|
-
insertOrIgnore(data:
|
|
161
|
-
upsert(data:
|
|
162
|
-
update(data:
|
|
162
|
+
insert(data: ModelAttributeInput<T> | ModelAttributeInput<T>[]): Promise<any>;
|
|
163
|
+
insertGetId(data: ModelAttributeInput<T>, idColumn?: ModelColumn<T>): Promise<any>;
|
|
164
|
+
insertOrIgnore(data: ModelAttributeInput<T> | ModelAttributeInput<T>[]): Promise<any>;
|
|
165
|
+
upsert(data: ModelAttributeInput<T> | ModelAttributeInput<T>[], uniqueBy: ModelColumn<T> | ModelColumn<T>[], updateColumns?: ModelColumn<T>[]): Promise<any>;
|
|
166
|
+
update(data: ModelAttributeInput<T>): Promise<any>;
|
|
163
167
|
delete(): Promise<any>;
|
|
164
|
-
increment(column:
|
|
165
|
-
decrement(column:
|
|
168
|
+
increment(column: ModelColumn<T>, amount?: number, extra?: ModelAttributeInput<T>): Promise<any>;
|
|
169
|
+
decrement(column: ModelColumn<T>, amount?: number, extra?: ModelAttributeInput<T>): Promise<any>;
|
|
166
170
|
restore(): Promise<any>;
|
|
167
171
|
exists(): Promise<boolean>;
|
|
168
172
|
doesntExist(): Promise<boolean>;
|
|
169
173
|
sole(): Promise<T>;
|
|
170
|
-
value(column:
|
|
174
|
+
value<K extends ModelColumn<T>>(column: K): Promise<ModelColumnValue<T, K> | null>;
|
|
171
175
|
dump(): this;
|
|
172
176
|
dd(): never;
|
|
173
177
|
explain(): Promise<any[]>;
|
package/package.json
CHANGED