@h3ravel/arquebus 0.4.1 → 0.6.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.
Files changed (45) hide show
  1. package/README.md +20 -1
  2. package/bin/index.cjs +225 -171
  3. package/bin/index.js +208 -122
  4. package/bin/seeders-8GJzfIIN.js +3 -0
  5. package/bin/seeders-ByeSoCAQ.cjs +131 -0
  6. package/bin/seeders-CltigymO.js +79 -0
  7. package/bin/seeders-_xJ6VGVS.cjs +3 -0
  8. package/dist/browser/index.cjs +9 -9
  9. package/dist/browser/index.d.cts +3655 -183
  10. package/dist/browser/index.d.ts +3655 -183
  11. package/dist/browser/index.js +9 -9
  12. package/dist/index.cjs +270 -135
  13. package/dist/index.d.cts +3797 -294
  14. package/dist/index.d.ts +3797 -294
  15. package/dist/index.js +263 -133
  16. package/dist/inspector/index.cjs +122 -46
  17. package/dist/inspector/index.js +119 -46
  18. package/dist/migrations/index.cjs +171 -151
  19. package/dist/migrations/index.d.cts +3510 -27
  20. package/dist/migrations/index.d.ts +3510 -27
  21. package/dist/migrations/index.js +177 -150
  22. package/dist/migrations/stubs/migration-js.stub +1 -1
  23. package/dist/migrations/stubs/migration-ts.stub +1 -1
  24. package/dist/migrations/stubs/migration.create-js.stub +5 -5
  25. package/dist/migrations/stubs/migration.create-ts.stub +5 -5
  26. package/dist/migrations/stubs/migration.update-js.stub +2 -2
  27. package/dist/migrations/stubs/migration.update-ts.stub +3 -3
  28. package/dist/seeders/index.cjs +141 -0
  29. package/dist/seeders/index.d.cts +4766 -0
  30. package/dist/seeders/index.d.ts +4766 -0
  31. package/dist/seeders/index.js +118 -0
  32. package/dist/seeders/index.ts +3 -0
  33. package/dist/seeders/runner.ts +102 -0
  34. package/dist/seeders/seeder-creator.ts +42 -0
  35. package/dist/seeders/seeder.ts +10 -0
  36. package/dist/stubs/seeder-js.stub +13 -0
  37. package/dist/stubs/seeder-ts.stub +9 -0
  38. package/package.json +15 -4
  39. package/types/builder.ts +158 -80
  40. package/types/container.ts +79 -66
  41. package/types/generics.ts +75 -36
  42. package/types/modeling.ts +213 -158
  43. package/types/query-builder.ts +223 -186
  44. package/types/query-methods.ts +160 -104
  45. package/types/utils.ts +64 -55
@@ -0,0 +1,118 @@
1
+ import path from "path";
2
+ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import path$1, { dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ //#region src/seeders/seeder.ts
7
+ var Seeder = class {};
8
+ var seeder_default = Seeder;
9
+
10
+ //#endregion
11
+ //#region src/seeders/runner.ts
12
+ async function glob(folderPath) {
13
+ const { default: escalade } = await import("escalade");
14
+ const entries = [];
15
+ await escalade(folderPath, async (dir, names) => {
16
+ await Promise.all(names.map(async (name) => {
17
+ const p = path.join(dir, name);
18
+ try {
19
+ await access(p);
20
+ if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
21
+ } catch {}
22
+ }));
23
+ return "";
24
+ });
25
+ return entries;
26
+ }
27
+ var SeederRunner = class {
28
+ resolver;
29
+ connection;
30
+ paths = [];
31
+ constructor(resolver) {
32
+ this.resolver = resolver;
33
+ }
34
+ path(p) {
35
+ this.paths = Array.from(new Set([...this.paths, p]));
36
+ }
37
+ getPaths() {
38
+ return this.paths;
39
+ }
40
+ resolveConnection(connection) {
41
+ var _getInstance, _ref, _instance$connections;
42
+ const name = connection || this.connection || "default";
43
+ const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
44
+ if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
45
+ /** noop */
46
+ });
47
+ return this.resolver.fire(name);
48
+ }
49
+ setConnection(connection) {
50
+ this.connection = connection;
51
+ return this;
52
+ }
53
+ async getSeederFiles(paths) {
54
+ const files = [];
55
+ for (const p of paths) {
56
+ if (p.endsWith(".js") || p.endsWith(".ts")) {
57
+ files.push(p);
58
+ continue;
59
+ }
60
+ files.push(...await glob(p));
61
+ }
62
+ return files;
63
+ }
64
+ async resolvePath(filePath) {
65
+ try {
66
+ const mod = await import(filePath);
67
+ return new (mod.default ?? mod.Seeder)();
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+ async run(paths, connection) {
73
+ const files = await this.getSeederFiles(paths);
74
+ const conn = this.resolveConnection(connection);
75
+ for (const file of files) {
76
+ const seeder = await this.resolvePath(file);
77
+ if (seeder && typeof seeder.run === "function") await seeder.run(conn);
78
+ }
79
+ }
80
+ };
81
+ var runner_default = SeederRunner;
82
+
83
+ //#endregion
84
+ //#region node_modules/.pnpm/tsdown@0.15.6_typescript@5.9.3/node_modules/tsdown/esm-shims.js
85
+ const getFilename = () => fileURLToPath(import.meta.url);
86
+ const getDirname = () => path$1.dirname(getFilename());
87
+ const __dirname = /* @__PURE__ */ getDirname();
88
+
89
+ //#endregion
90
+ //#region src/seeders/seeder-creator.ts
91
+ var SeederCreator = class {
92
+ constructor(customStubPath) {
93
+ this.customStubPath = customStubPath;
94
+ }
95
+ async create(dir, name, type = "js") {
96
+ await mkdir(dir, { recursive: true });
97
+ const stubPath = this.getStubPath(type);
98
+ let stub = await readFile(stubPath, "utf-8");
99
+ stub = stub.replace(/{{ name }}/g, name);
100
+ const filePath = path.join(dir, `${name}.${type}`);
101
+ await writeFile(filePath, stub);
102
+ return filePath;
103
+ }
104
+ getStubPath(type) {
105
+ if (this.customStubPath) return path.join(this.customStubPath, `seeder-${type}.stub`);
106
+ const __dirname$1 = this.getDirname(import.meta);
107
+ return path.join(__dirname$1, "stubs", `seeder-${type}.stub`);
108
+ }
109
+ getDirname(meta) {
110
+ if (typeof __dirname !== "undefined") return __dirname;
111
+ if (meta && meta.url) return dirname(fileURLToPath(meta.url));
112
+ throw new Error("Unable to determine dirname");
113
+ }
114
+ };
115
+ var seeder_creator_default = SeederCreator;
116
+
117
+ //#endregion
118
+ export { seeder_default as Seeder, seeder_creator_default as SeederCreator, runner_default as SeederRunner };
@@ -0,0 +1,3 @@
1
+ export { default as Seeder } from './seeder'
2
+ export { default as SeederRunner } from './runner'
3
+ export { default as SeederCreator } from './seeder-creator'
@@ -0,0 +1,102 @@
1
+ import type QueryBuilder from 'src/query-builder'
2
+ import type { TBaseConfig } from 'types/container'
3
+ import type { arquebus } from 'src'
4
+ import path from 'path'
5
+ import { access } from 'node:fs/promises'
6
+
7
+ import Seeder from './seeder'
8
+
9
+ async function glob(folderPath: string): Promise<string[]> {
10
+ const { default: escalade } = await import('escalade')
11
+ const entries: string[] = []
12
+ const root = folderPath
13
+ await escalade(root, async (dir, names) => {
14
+ await Promise.all(
15
+ names.map(async (name) => {
16
+ const p = path.join(dir, name)
17
+ try {
18
+ await access(p)
19
+ if (p.endsWith('.js') || p.endsWith('.ts')) entries.push(p)
20
+ } catch {
21
+ /** */
22
+ }
23
+ }),
24
+ )
25
+ return ''
26
+ })
27
+ return entries
28
+ }
29
+
30
+ export class SeederRunner {
31
+ resolver: typeof arquebus
32
+ connection!: TBaseConfig['client']
33
+ paths: string[] = []
34
+
35
+ constructor(resolver: typeof arquebus) {
36
+ this.resolver = resolver
37
+ }
38
+
39
+ path(p: string): void {
40
+ this.paths = Array.from(new Set([...this.paths, p]))
41
+ }
42
+
43
+ getPaths(): string[] {
44
+ return this.paths
45
+ }
46
+
47
+ resolveConnection(connection?: TBaseConfig['client']): QueryBuilder {
48
+ const name = connection || this.connection || 'default'
49
+ // If the resolver has no connection manager entry, attempt to autoload config
50
+ const instance: any = (this.resolver as any).getInstance?.() ?? null
51
+ const hasConn = !!instance?.connections?.[name]
52
+ if (!hasConn) {
53
+ // Attempt autoload; do not throw if empty
54
+ this.resolver
55
+ .autoLoad()
56
+ .catch(() => {
57
+ /** noop */
58
+ })
59
+ }
60
+ return this.resolver.fire(name)
61
+ }
62
+
63
+ setConnection(connection: TBaseConfig['client']): this {
64
+ this.connection = connection
65
+ return this
66
+ }
67
+
68
+ async getSeederFiles(paths: string[]): Promise<string[]> {
69
+ const files: string[] = []
70
+ for (const p of paths) {
71
+ if (p.endsWith('.js') || p.endsWith('.ts')) {
72
+ files.push(p)
73
+ continue
74
+ }
75
+ files.push(...(await glob(p)))
76
+ }
77
+ return files
78
+ }
79
+
80
+ async resolvePath(filePath: string): Promise<Seeder | null> {
81
+ try {
82
+ const mod = await import(filePath)
83
+ const instance = new (mod.default ?? mod.Seeder)()
84
+ return instance as Seeder
85
+ } catch {
86
+ return null
87
+ }
88
+ }
89
+
90
+ async run(paths: string[], connection?: TBaseConfig['client']): Promise<void> {
91
+ const files = await this.getSeederFiles(paths)
92
+ const conn = this.resolveConnection(connection)
93
+ for (const file of files) {
94
+ const seeder = await this.resolvePath(file)
95
+ if (seeder && typeof seeder.run === 'function') {
96
+ await seeder.run(conn)
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ export default SeederRunner
@@ -0,0 +1,42 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises'
2
+
3
+ import { dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+ import path from 'path'
6
+
7
+ export class SeederCreator {
8
+ constructor(private customStubPath?: string) { }
9
+
10
+ async create (dir: string, name: string, type: 'js' | 'ts' = 'js') {
11
+ await mkdir(dir, { recursive: true })
12
+
13
+ const stubPath = this.getStubPath(type)
14
+ let stub = await readFile(stubPath, 'utf-8')
15
+ stub = stub.replace(/{{ name }}/g, name)
16
+
17
+ const filePath = path.join(dir, `${name}.${type}`)
18
+ await writeFile(filePath, stub)
19
+
20
+ return filePath
21
+ }
22
+
23
+ getStubPath (type: 'js' | 'ts') {
24
+ if (this.customStubPath) return path.join(this.customStubPath, `seeder-${type}.stub`)
25
+ const __dirname = this.getDirname(import.meta as any)
26
+ return path.join(__dirname, 'stubs', `seeder-${type}.stub`)
27
+ }
28
+
29
+ getDirname (meta: ImportMeta | null) {
30
+ if (typeof __dirname !== 'undefined') {
31
+ // CJS build
32
+ return __dirname
33
+ }
34
+ if (meta && meta.url) {
35
+ // ESM build
36
+ return dirname(fileURLToPath(meta.url))
37
+ }
38
+ throw new Error('Unable to determine dirname')
39
+ }
40
+ }
41
+
42
+ export default SeederCreator
@@ -0,0 +1,10 @@
1
+ import type QueryBuilder from 'src/query-builder'
2
+
3
+ export abstract class Seeder {
4
+ /**
5
+ * Run the database seeds
6
+ */
7
+ abstract run(connection: QueryBuilder): Promise<void>
8
+ }
9
+
10
+ export default Seeder
@@ -0,0 +1,13 @@
1
+ import { Seeder } from '@h3ravel/arquebus'
2
+
3
+ export default class {{ name }} extends Seeder {
4
+ /**
5
+ * Run the seeder.
6
+ *
7
+ * @param {(import('@h3ravel/arquebus').QueryBuilder)} connection
8
+ */
9
+ async run(connection) {
10
+ // Example: insert sample data
11
+ await connection.table('users').insert({ name: 'John Doe' })
12
+ }
13
+ }
@@ -0,0 +1,9 @@
1
+ import type { QueryBuilder } from '@h3ravel/arquebus'
2
+ import { Seeder } from '@h3ravel/arquebus'
3
+
4
+ export default class {{ name }} extends Seeder {
5
+ async run(connection: QueryBuilder) {
6
+ // Example: insert sample data
7
+ await connection.table('users').insert({ name: 'John Doe' })
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/arquebus",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Arquebus ORM is a Beautiful, expressive ORM inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework.",
5
5
  "homepage": "https://h3ravel.toneflix.net/arquebus",
6
6
  "bin": {
@@ -91,6 +91,16 @@
91
91
  "default": "./dist/inspector/index.cjs"
92
92
  }
93
93
  },
94
+ "./seeders": {
95
+ "import": {
96
+ "types": "./dist/seeders/index.d.ts",
97
+ "default": "./dist/seeders/index.js"
98
+ },
99
+ "require": {
100
+ "types": "./dist/seeders/index.d.cts",
101
+ "default": "./dist/seeders/index.cjs"
102
+ }
103
+ },
94
104
  "./browser": {
95
105
  "import": {
96
106
  "types": "./dist/browser/index.d.ts",
@@ -123,7 +133,8 @@
123
133
  ]
124
134
  },
125
135
  "dependencies": {
126
- "@h3ravel/shared": "^0.18.1",
136
+ "@h3ravel/shared": "^0.20.12",
137
+ "@h3ravel/support": "^0.12.0",
127
138
  "chalk": "^5.6.2",
128
139
  "collect.js": "^4.36.1",
129
140
  "commander": "^14.0.1",
@@ -137,7 +148,6 @@
137
148
  "mysql2": "^3.15.0",
138
149
  "pg": "^8.16.3",
139
150
  "pluralize": "^8.0.0",
140
- "prettier": "^3.6.2",
141
151
  "radashi": "^12.6.2",
142
152
  "resolve-from": "^5.0.0",
143
153
  "tedious": "^19.0.0"
@@ -151,6 +161,7 @@
151
161
  "@vitest/coverage-v8": "^3.2.4",
152
162
  "eslint": "^9.36.0",
153
163
  "jsdom": "^26.1.0",
164
+ "prettier": "^3.6.2",
154
165
  "sqlite3": "5.1.7",
155
166
  "terser": "^5.44.0",
156
167
  "ts-node": "^10.9.2",
@@ -185,6 +196,6 @@
185
196
  "test:postgres": "cross-env DB=postgres vitest --project node",
186
197
  "test:sqlite": "cross-env DB=sqlite vitest --project node",
187
198
  "test:browser": "vitest --project browser",
188
- "release:patch": "pnpm build && git add . && git commit -m \"version: bump version and publish\" && pnpm version patch && pnpm publish --tag latest"
199
+ "release:patch": "pnpm build && git add . && git commit -m \"version: bump version\" && pnpm version patch && pnpm publish --tag latest"
189
200
  }
190
201
  }
package/types/builder.ts CHANGED
@@ -5,90 +5,168 @@ import type BModel from 'src/browser/model'
5
5
  import type Builder from 'src/builder'
6
6
  import type { IModel } from './modeling'
7
7
  import type { IQueryBuilder } from './query-builder'
8
+ import type { Knex } from 'knex'
8
9
  import type Model from 'src/model'
10
+ import type { TFunction } from './generics'
9
11
 
10
- // type BaseBuilder<M extends Model, R> = Omit<
11
- // IQueryBuilder<M, R>,
12
- // 'destroy' | 'clone' | 'get' | 'skip' | 'limit' | 'take' | 'offset' | 'chunk' | 'forPage'
13
- // >
12
+ type BaseBuilder<M extends Model | BModel, R = ICollection<M> | IModel> = Omit<
13
+ IQueryBuilder<M, R>,
14
+ | 'destroy'
15
+ | 'clone'
16
+ | 'get'
17
+ | 'skip'
18
+ | 'limit'
19
+ | 'take'
20
+ | 'offset'
21
+ | 'chunk'
22
+ | 'forPage'
23
+ | 'orWhere'
24
+ | 'pluck'
25
+ >
14
26
 
15
27
  export interface IScope {
16
- apply (builder: Builder<any>, model: Model): void;
28
+ apply(builder: Builder<any>, model: Model): void
17
29
  }
18
30
 
19
-
20
- export interface IBuilder<M extends Model | BModel, R = ICollection<M> | IModel> extends IQueryBuilder<M, R> {
21
- asProxy (): IQueryBuilder<M, R>;
22
- // chunk (count: number, callback: (rows: ICollection<M>) => any): Promise<boolean>;
23
- enforceOrderBy (): void;
24
- // clone (): IBuilder<M, R>;
25
- // forPage (page: number, perPage?: number): this;
26
- insert (attributes: any): Promise<any>;
27
- update (attributes: any): Promise<any>;
28
- increment (column: string, amount?: number, extra?: any): Promise<any>;
29
- decrement (column: string, amount?: number, extra?: any): Promise<any>;
30
- addUpdatedAtColumn (values: any): any;
31
- delete (): Promise<boolean | number>;
32
- softDelete (): boolean | Promise<any>;
33
- forceDelete (): boolean | Promise<any>;
34
- restore (): boolean | Promise<any>;
35
- withTrashed (): this;
36
- withoutTrashed (): this;
37
- onlyTrashed (): this;
38
- getDeletedAtColumn (): string;
39
- create (attributes?: any): Promise<M>;
40
- newModelInstance (attributes?: any): M;
41
- count (columns?: string): Promise<number>;
42
- getQuery (): AnyQueryBuilder;
43
- getModel (): M;
44
- setModel (model: M): this;
45
- setTable (table: string): this;
46
- applyScopes (): this;
47
- scopes (scopes: string[]): this;
48
- withGlobalScope (identifier: string | number, scope: string | (() => void)): this;
49
- withoutGlobalScope (scope: IScope | string): this;
50
- with (relation: WithRelationType): this;
51
- with (...relations: WithRelationType[]): this;
52
- has (relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
53
- orHas (relation: string, operator?: any, count?: number): this;
54
- doesntHave (relation: string, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
55
- orDoesntHave (relation: string): this;
56
- whereHas (relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
57
- orWhereHas (relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
58
- whereRelation (relation: string, column: string, operator?: any, value?: any): this;
59
- hasNested (relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
60
- canUseExistsForExistenceCheck (operator: string, count: number): boolean;
61
- addHasWhere (hasQuery: IBuilder<any>, relation: string, operator?: string, count?: number, boolean?: string): this;
62
- withAggregate (relations: string | string[] | object, column: string, action?: string | null): this;
63
- toSql (): object;
64
- withCount (...relations: WithRelationType[]): this;
65
- withMax (relation: WithRelationType, column: string): this;
66
- withMin (relation: WithRelationType, column: string): this;
67
- withAvg (relation: WithRelationType, column: string): this;
68
- withSum (relation: WithRelationType, column: string): this;
69
- withExists (relation: WithRelationType): this;
70
- related (relation: string): this;
71
- // take (count: number): this;
72
- // skip (count: number): this;
73
- // limit (count: number): this;
74
- // offset (count: number): this;
75
- first (column?: string | string[]): Promise<M | null | undefined>;
76
- firstOrFail (column?: string | string[]): Promise<M>;
77
- findOrFail (key: string | number, columns?: string[]): Promise<M>;
78
- findOrFail (key: string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
79
- findOrFail (key: string | number | string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
80
- findOrNew (id: string | number, columns?: string[]): Promise<M>;
81
- firstOrNew (attributes?: object, values?: object): Promise<M>;
82
- firstOrCreate (attributes?: object, values?: object): Promise<M>;
83
- updateOrCreate (attributes: object, values?: object): Promise<M>;
84
- latest (column?: string): this;
85
- oldest (column?: string): this;
86
- find (key: string | number, columns?: string[]): Promise<M | null | undefined>;
87
- findMany (keys: string[] | number[] | ICollection<any>, columns?: string[]): Promise<ICollection<M>>;
88
- pluck<X extends Model = any | M> (column: string): Promise<ICollection<X>>;
89
- // destroy (ids: string | number | string[] | number[] | ICollection<any>): Promise<number>;
90
- // get (columns?: string[]): Promise<ICollection<M>>;
91
- all (columns?: string[]): Promise<ICollection<M>>;
92
- paginate<F extends IPaginatorParams> (page?: number, perPage?: number): Promise<IPaginator<M, F>>;
93
- [value: string]: any;
31
+ // @ts-expect-error Errors will come from builder differences but that is fine
32
+ export interface IBuilder<M extends Model | BModel, R = ICollection<M> | IModel>
33
+ extends BaseBuilder<M, R> {
34
+ connector: IQueryBuilder<M, R> &
35
+ Knex.QueryBuilder & { _statements: any[]; _single: any } & Knex
36
+ asProxy(): IQueryBuilder<M, R>
37
+ chunk(
38
+ count: number,
39
+ callback: (rows: ICollection<M>) => any,
40
+ ): Promise<boolean>
41
+ enforceOrderBy(): void
42
+ idOf(id: string | number): this
43
+ clone(): IBuilder<M, R>
44
+ forPage(page: number, perPage?: number): this
45
+ insert(...attributes: any[]): Promise<any>
46
+ update(attributes: any): Promise<any>
47
+ increment(column: string, amount?: number, extra?: any): Promise<any>
48
+ decrement(column: string, amount?: number, extra?: any): Promise<any>
49
+ addUpdatedAtColumn(values: any): any
50
+ delete(): Promise<boolean | number>
51
+ softDelete(): boolean | Promise<any>
52
+ forceDelete(): boolean | Promise<any>
53
+ restore(): boolean | Promise<any>
54
+ withTrashed(): this
55
+ withoutTrashed(): this
56
+ onlyTrashed(): this
57
+ getDeletedAtColumn(): string
58
+ create(attributes?: any): Promise<M>
59
+ newModelInstance(attributes?: any): M
60
+ count(columns?: string): Promise<number>
61
+ getQuery(): AnyQueryBuilder
62
+ getModel(): M
63
+ setModel(model: M): this
64
+ setTable(table: string): this
65
+ applyScopes(): this
66
+ scopes(scopes: string[]): this
67
+ withGlobalScope(
68
+ identifier: string | number,
69
+ scope: string | (() => void),
70
+ ): this
71
+ withoutGlobalScope(scope: IScope | string): this
72
+ with(relation: WithRelationType): this
73
+ with(...relations: WithRelationType[]): this
74
+ has(
75
+ relation: string,
76
+ operator?: any,
77
+ count?: number,
78
+ boolean?: any,
79
+ callback?: (builder: IBuilder<any>) => void | null,
80
+ ): this
81
+ orHas(relation: string, operator?: any, count?: number): this
82
+ doesntHave(
83
+ relation: string,
84
+ boolean?: any,
85
+ callback?: (builder: IBuilder<any>) => void | null,
86
+ ): this
87
+ orDoesntHave(relation: string): this
88
+ whereHas(
89
+ relation: string,
90
+ callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null,
91
+ operator?: any,
92
+ count?: number,
93
+ ): this
94
+ orWhere(...args: any[]): this
95
+ orWhereHas(
96
+ relation: string,
97
+ callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null,
98
+ operator?: any,
99
+ count?: number,
100
+ ): this
101
+ whereRelation(
102
+ relation: string,
103
+ column: string,
104
+ operator?: any,
105
+ value?: any,
106
+ ): this
107
+ hasNested(
108
+ relation: string,
109
+ operator?: any,
110
+ count?: number,
111
+ boolean?: any,
112
+ callback?: (builder: IBuilder<any>) => void | null,
113
+ ): this
114
+ canUseExistsForExistenceCheck(operator: string, count: number): boolean
115
+ addHasWhere(
116
+ hasQuery: IBuilder<any>,
117
+ relation: string,
118
+ operator?: string,
119
+ count?: number,
120
+ boolean?: string,
121
+ ): this
122
+ withAggregate(
123
+ relations: string | string[] | object,
124
+ column: string,
125
+ action?: string | null,
126
+ ): this
127
+ toSql(): object
128
+ withCount(...relations: WithRelationType[]): this
129
+ withMax(relation: WithRelationType, column: string): this
130
+ withMin(relation: WithRelationType, column: string): this
131
+ withAvg(relation: WithRelationType, column: string): this
132
+ withSum(relation: WithRelationType, column: string): this
133
+ withExists(relation: WithRelationType): this
134
+ related(relation: string): this
135
+ take(count: number): this
136
+ skip(count: number): this
137
+ limit(count: number): this
138
+ offset(count: number): this
139
+ first(column?: string | string[]): Promise<M | null | undefined>
140
+ firstOrFail(column?: string | string[]): Promise<M>
141
+ findOrFail(key: string | number, columns?: string[]): Promise<M>
142
+ findOrFail(
143
+ key: string[] | number[] | ICollection<any>,
144
+ columns?: string[],
145
+ ): Promise<M>
146
+ findOrFail(
147
+ key: string | number | string[] | number[] | ICollection<any>,
148
+ columns?: string[],
149
+ ): Promise<M>
150
+ findOrNew(id: string | number, columns?: string[]): Promise<M>
151
+ firstOrNew(attributes?: object, values?: object): Promise<M>
152
+ firstOrCreate(attributes?: object, values?: object): Promise<M>
153
+ updateOrCreate(attributes: object, values?: object): Promise<M>
154
+ latest(column?: string): this
155
+ oldest(column?: string): this
156
+ find(key: string | number, columns?: string[]): Promise<M | null | undefined>
157
+ findMany(
158
+ keys: string[] | number[] | ICollection<any>,
159
+ columns?: string[],
160
+ ): Promise<ICollection<M>>
161
+ pluck<X extends Model = any | M>(column: string): Promise<ICollection<X>>
162
+ destroy(
163
+ ids?: string | number | string[] | number[] | TFunction | ICollection<any>,
164
+ ): Promise<number>
165
+ get(columns?: string[]): Promise<ICollection<M>>
166
+ all(columns?: string[]): Promise<ICollection<M>>
167
+ paginate<F extends IPaginatorParams>(
168
+ page?: number,
169
+ perPage?: number,
170
+ ): Promise<IPaginator<M, F>>
171
+ [value: string]: any
94
172
  }