@h3ravel/arquebus 0.5.0 → 0.6.1

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 +197 -145
  3. package/bin/index.js +178 -95
  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 +8 -8
  10. package/dist/browser/index.d.ts +8 -8
  11. package/dist/browser/index.js +9 -9
  12. package/dist/index.cjs +252 -121
  13. package/dist/index.d.cts +41 -9
  14. package/dist/index.d.ts +41 -9
  15. package/dist/index.js +245 -119
  16. package/dist/inspector/index.cjs +105 -33
  17. package/dist/inspector/index.js +102 -33
  18. package/dist/migrations/index.cjs +144 -126
  19. package/dist/migrations/index.d.cts +11 -11
  20. package/dist/migrations/index.d.ts +11 -11
  21. package/dist/migrations/index.js +148 -130
  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 +101 -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 +14 -3
  39. package/types/builder.ts +153 -80
  40. package/types/container.ts +79 -66
  41. package/types/generics.ts +75 -37
  42. package/types/modeling.ts +213 -158
  43. package/types/query-builder.ts +221 -191
  44. package/types/query-methods.ts +145 -109
  45. package/types/utils.ts +64 -56
@@ -0,0 +1,118 @@
1
+ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import path from "path";
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,101 @@
1
+ import type QueryBuilder from 'src/query-builder'
2
+ import type Seeder from './seeder'
3
+ import type { TBaseConfig } from 'types/container'
4
+ import { access } from 'node:fs/promises'
5
+ import type { arquebus } from 'src'
6
+ import path from 'path'
7
+
8
+ async function glob (folderPath: string): Promise<string[]> {
9
+ const { default: escalade } = await import('escalade')
10
+ const entries: string[] = []
11
+ const root = folderPath
12
+ await escalade(root, async (dir, names) => {
13
+ await Promise.all(
14
+ names.map(async (name) => {
15
+ const p = path.join(dir, name)
16
+ try {
17
+ await access(p)
18
+ if (p.endsWith('.js') || p.endsWith('.ts')) entries.push(p)
19
+ } catch {
20
+ /** */
21
+ }
22
+ }),
23
+ )
24
+ return ''
25
+ })
26
+ return entries
27
+ }
28
+
29
+ export class SeederRunner {
30
+ resolver: typeof arquebus
31
+ connection!: TBaseConfig['client']
32
+ paths: string[] = []
33
+
34
+ constructor(resolver: typeof arquebus) {
35
+ this.resolver = resolver
36
+ }
37
+
38
+ path (p: string): void {
39
+ this.paths = Array.from(new Set([...this.paths, p]))
40
+ }
41
+
42
+ getPaths (): string[] {
43
+ return this.paths
44
+ }
45
+
46
+ resolveConnection (connection?: TBaseConfig['client']): QueryBuilder {
47
+ const name = connection || this.connection || 'default'
48
+ // If the resolver has no connection manager entry, attempt to autoload config
49
+ const instance: any = (this.resolver as any).getInstance?.() ?? null
50
+ const hasConn = !!instance?.connections?.[name]
51
+ if (!hasConn) {
52
+ // Attempt autoload; do not throw if empty
53
+ this.resolver
54
+ .autoLoad()
55
+ .catch(() => {
56
+ /** noop */
57
+ })
58
+ }
59
+ return this.resolver.fire(name)
60
+ }
61
+
62
+ setConnection (connection: TBaseConfig['client']): this {
63
+ this.connection = connection
64
+ return this
65
+ }
66
+
67
+ async getSeederFiles (paths: string[]): Promise<string[]> {
68
+ const files: string[] = []
69
+ for (const p of paths) {
70
+ if (p.endsWith('.js') || p.endsWith('.ts')) {
71
+ files.push(p)
72
+ continue
73
+ }
74
+ files.push(...(await glob(p)))
75
+ }
76
+ return files
77
+ }
78
+
79
+ async resolvePath (filePath: string): Promise<Seeder | null> {
80
+ try {
81
+ const mod = await import(filePath)
82
+ const instance = new (mod.default ?? mod.Seeder)()
83
+ return instance as Seeder
84
+ } catch {
85
+ return null
86
+ }
87
+ }
88
+
89
+ async run (paths: string[], connection?: TBaseConfig['client']): Promise<void> {
90
+ const files = await this.getSeederFiles(paths)
91
+ const conn = this.resolveConnection(connection)
92
+ for (const file of files) {
93
+ const seeder = await this.resolvePath(file)
94
+ if (seeder && typeof seeder.run === 'function') {
95
+ await seeder.run(conn)
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+ 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.5.0",
3
+ "version": "0.6.1",
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.20.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",
package/types/builder.ts CHANGED
@@ -10,90 +10,163 @@ import type Model from 'src/model'
10
10
  import type { TFunction } from './generics'
11
11
 
12
12
  type BaseBuilder<M extends Model | BModel, R = ICollection<M> | IModel> = Omit<
13
- IQueryBuilder<M, R>,
14
- 'destroy' | 'clone' | 'get' | 'skip' | 'limit' | 'take' | 'offset' | 'chunk' | 'forPage' | 'orWhere' | 'pluck'
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'
15
25
  >
16
26
 
17
27
  export interface IScope {
18
- apply (builder: Builder<any>, model: Model): void;
28
+ apply(builder: Builder<any>, model: Model): void
19
29
  }
20
30
 
21
31
  // @ts-expect-error Errors will come from builder differences but that is fine
22
- export interface IBuilder<M extends Model | BModel, R = ICollection<M> | IModel> extends BaseBuilder<M, R> {
23
- connector: IQueryBuilder<M, R> & Knex.QueryBuilder & { _statements: any[], _single: any } & Knex
24
- asProxy (): IQueryBuilder<M, R>;
25
- chunk (count: number, callback: (rows: ICollection<M>) => any): Promise<boolean>;
26
- enforceOrderBy (): void;
27
- idOf (id: string | number): this;
28
- clone (): IBuilder<M, R>;
29
- forPage (page: number, perPage?: number): this;
30
- insert (...attributes: any[]): Promise<any>;
31
- update (attributes: any): Promise<any>;
32
- increment (column: string, amount?: number, extra?: any): Promise<any>;
33
- decrement (column: string, amount?: number, extra?: any): Promise<any>;
34
- addUpdatedAtColumn (values: any): any;
35
- delete (): Promise<boolean | number>;
36
- softDelete (): boolean | Promise<any>;
37
- forceDelete (): boolean | Promise<any>;
38
- restore (): boolean | Promise<any>;
39
- withTrashed (): this;
40
- withoutTrashed (): this;
41
- onlyTrashed (): this;
42
- getDeletedAtColumn (): string;
43
- create (attributes?: any): Promise<M>;
44
- newModelInstance (attributes?: any): M;
45
- count (columns?: string): Promise<number>;
46
- getQuery (): AnyQueryBuilder;
47
- getModel (): M;
48
- setModel (model: M): this;
49
- setTable (table: string): this;
50
- applyScopes (): this;
51
- scopes (scopes: string[]): this;
52
- withGlobalScope (identifier: string | number, scope: string | (() => void)): this;
53
- withoutGlobalScope (scope: IScope | string): this;
54
- with (relation: WithRelationType): this;
55
- with (...relations: WithRelationType[]): this;
56
- has (relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
57
- orHas (relation: string, operator?: any, count?: number): this;
58
- doesntHave (relation: string, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
59
- orDoesntHave (relation: string): this;
60
- whereHas (relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
61
- orWhere (...args: any[]): this
62
- orWhereHas (relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
63
- whereRelation (relation: string, column: string, operator?: any, value?: any): this;
64
- hasNested (relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
65
- canUseExistsForExistenceCheck (operator: string, count: number): boolean;
66
- addHasWhere (hasQuery: IBuilder<any>, relation: string, operator?: string, count?: number, boolean?: string): this;
67
- withAggregate (relations: string | string[] | object, column: string, action?: string | null): this;
68
- toSql (): object;
69
- withCount (...relations: WithRelationType[]): this;
70
- withMax (relation: WithRelationType, column: string): this;
71
- withMin (relation: WithRelationType, column: string): this;
72
- withAvg (relation: WithRelationType, column: string): this;
73
- withSum (relation: WithRelationType, column: string): this;
74
- withExists (relation: WithRelationType): this;
75
- related (relation: string): this;
76
- take (count: number): this;
77
- skip (count: number): this;
78
- limit (count: number): this;
79
- offset (count: number): this;
80
- first (column?: string | string[]): Promise<M | null | undefined>;
81
- firstOrFail (column?: string | string[]): Promise<M>;
82
- findOrFail (key: string | number, columns?: string[]): Promise<M>;
83
- findOrFail (key: string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
84
- findOrFail (key: string | number | string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
85
- findOrNew (id: string | number, columns?: string[]): Promise<M>;
86
- firstOrNew (attributes?: object, values?: object): Promise<M>;
87
- firstOrCreate (attributes?: object, values?: object): Promise<M>;
88
- updateOrCreate (attributes: object, values?: object): Promise<M>;
89
- latest (column?: string): this;
90
- oldest (column?: string): this;
91
- find (key: string | number, columns?: string[]): Promise<M | null | undefined>;
92
- findMany (keys: string[] | number[] | ICollection<any>, columns?: string[]): Promise<ICollection<M>>;
93
- pluck<X extends Model = any | M> (column: string): Promise<ICollection<X>>;
94
- destroy (ids?: string | number | string[] | number[] | TFunction | ICollection<any>): Promise<number>;
95
- get (columns?: string[]): Promise<ICollection<M>>;
96
- all (columns?: string[]): Promise<ICollection<M>>;
97
- paginate<F extends IPaginatorParams> (page?: number, perPage?: number): Promise<IPaginator<M, F>>;
98
- [value: string]: any;
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
99
172
  }