pqb 0.0.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.
- package/dist/index.d.ts +3630 -0
- package/dist/index.esm.js +4587 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +4691 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
- package/rollup.config.js +35 -0
- package/src/adapter.test.ts +10 -0
- package/src/adapter.ts +171 -0
- package/src/columnSchema/array.ts +21 -0
- package/src/columnSchema/boolean.ts +10 -0
- package/src/columnSchema/columnType.test.ts +129 -0
- package/src/columnSchema/columnType.ts +77 -0
- package/src/columnSchema/columnTypes.ts +145 -0
- package/src/columnSchema/columnsSchema.test.ts +32 -0
- package/src/columnSchema/columnsSchema.ts +100 -0
- package/src/columnSchema/commonMethods.ts +130 -0
- package/src/columnSchema/dateTime.ts +104 -0
- package/src/columnSchema/enum.ts +13 -0
- package/src/columnSchema/index.ts +11 -0
- package/src/columnSchema/json/array.ts +55 -0
- package/src/columnSchema/json/discriminatedUnion.ts +91 -0
- package/src/columnSchema/json/enum.ts +29 -0
- package/src/columnSchema/json/instanceOf.ts +16 -0
- package/src/columnSchema/json/intersection.ts +23 -0
- package/src/columnSchema/json/lazy.ts +22 -0
- package/src/columnSchema/json/literal.ts +12 -0
- package/src/columnSchema/json/map.ts +29 -0
- package/src/columnSchema/json/nativeEnum.ts +30 -0
- package/src/columnSchema/json/nullable.ts +33 -0
- package/src/columnSchema/json/nullish.ts +30 -0
- package/src/columnSchema/json/object.ts +206 -0
- package/src/columnSchema/json/optional.ts +28 -0
- package/src/columnSchema/json/record.ts +40 -0
- package/src/columnSchema/json/scalarTypes.ts +117 -0
- package/src/columnSchema/json/set.ts +34 -0
- package/src/columnSchema/json/tuple.ts +40 -0
- package/src/columnSchema/json/typeBase.ts +202 -0
- package/src/columnSchema/json/union.ts +16 -0
- package/src/columnSchema/json.ts +64 -0
- package/src/columnSchema/number.ts +122 -0
- package/src/columnSchema/string.ts +222 -0
- package/src/columnSchema/utils.ts +27 -0
- package/src/common.ts +86 -0
- package/src/db.test.ts +67 -0
- package/src/db.ts +212 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +18 -0
- package/src/operators.test.ts +608 -0
- package/src/operators.ts +177 -0
- package/src/query.ts +292 -0
- package/src/queryDataUtils.ts +50 -0
- package/src/queryMethods/aggregate.test.ts +583 -0
- package/src/queryMethods/aggregate.ts +878 -0
- package/src/queryMethods/callbacks.test.ts +69 -0
- package/src/queryMethods/callbacks.ts +55 -0
- package/src/queryMethods/clear.test.ts +64 -0
- package/src/queryMethods/clear.ts +58 -0
- package/src/queryMethods/columnInfo.test.ts +45 -0
- package/src/queryMethods/columnInfo.ts +67 -0
- package/src/queryMethods/delete.test.ts +135 -0
- package/src/queryMethods/delete.ts +50 -0
- package/src/queryMethods/for.test.ts +57 -0
- package/src/queryMethods/for.ts +99 -0
- package/src/queryMethods/from.test.ts +66 -0
- package/src/queryMethods/from.ts +58 -0
- package/src/queryMethods/get.test.ts +66 -0
- package/src/queryMethods/get.ts +88 -0
- package/src/queryMethods/having.test.ts +247 -0
- package/src/queryMethods/having.ts +99 -0
- package/src/queryMethods/insert.test.ts +555 -0
- package/src/queryMethods/insert.ts +453 -0
- package/src/queryMethods/join.test.ts +150 -0
- package/src/queryMethods/join.ts +508 -0
- package/src/queryMethods/json.test.ts +398 -0
- package/src/queryMethods/json.ts +259 -0
- package/src/queryMethods/log.test.ts +172 -0
- package/src/queryMethods/log.ts +123 -0
- package/src/queryMethods/queryMethods.test.ts +629 -0
- package/src/queryMethods/queryMethods.ts +428 -0
- package/src/queryMethods/select.test.ts +479 -0
- package/src/queryMethods/select.ts +249 -0
- package/src/queryMethods/then.ts +236 -0
- package/src/queryMethods/transaction.test.ts +66 -0
- package/src/queryMethods/transaction.ts +66 -0
- package/src/queryMethods/union.test.ts +59 -0
- package/src/queryMethods/union.ts +89 -0
- package/src/queryMethods/update.test.ts +417 -0
- package/src/queryMethods/update.ts +350 -0
- package/src/queryMethods/upsert.test.ts +56 -0
- package/src/queryMethods/upsert.ts +43 -0
- package/src/queryMethods/where.test.ts +1594 -0
- package/src/queryMethods/where.ts +450 -0
- package/src/queryMethods/window.test.ts +66 -0
- package/src/queryMethods/window.ts +108 -0
- package/src/queryMethods/with.test.ts +191 -0
- package/src/queryMethods/with.ts +92 -0
- package/src/quote.ts +36 -0
- package/src/relations.ts +194 -0
- package/src/sql/aggregate.ts +80 -0
- package/src/sql/columnInfo.ts +22 -0
- package/src/sql/common.ts +42 -0
- package/src/sql/delete.ts +41 -0
- package/src/sql/distinct.ts +19 -0
- package/src/sql/fromAndAs.ts +51 -0
- package/src/sql/having.ts +140 -0
- package/src/sql/index.ts +2 -0
- package/src/sql/insert.ts +102 -0
- package/src/sql/join.ts +242 -0
- package/src/sql/orderBy.ts +41 -0
- package/src/sql/select.ts +153 -0
- package/src/sql/toSql.ts +153 -0
- package/src/sql/truncate.ts +13 -0
- package/src/sql/types.ts +355 -0
- package/src/sql/update.ts +62 -0
- package/src/sql/where.ts +314 -0
- package/src/sql/window.ts +38 -0
- package/src/sql/with.ts +32 -0
- package/src/test-utils.ts +172 -0
- package/src/utils.ts +140 -0
- package/tsconfig.build.json +6 -0
- package/tsconfig.json +8 -0
package/src/common.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Query, Selectable } from './query';
|
|
2
|
+
import { ColumnOutput, ColumnType } from './columnSchema';
|
|
3
|
+
|
|
4
|
+
export type AliasOrTable<T extends Pick<Query, 'tableAlias' | 'table'>> =
|
|
5
|
+
T['tableAlias'] extends string
|
|
6
|
+
? T['tableAlias']
|
|
7
|
+
: T['table'] extends string
|
|
8
|
+
? T['table']
|
|
9
|
+
: never;
|
|
10
|
+
|
|
11
|
+
export type StringKey<K extends PropertyKey> = Exclude<K, symbol | number>;
|
|
12
|
+
|
|
13
|
+
export type RawExpression<C extends ColumnType = ColumnType> = {
|
|
14
|
+
__raw: string;
|
|
15
|
+
__values: unknown[];
|
|
16
|
+
__column: C;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type Expression<
|
|
20
|
+
T extends Query = Query,
|
|
21
|
+
C extends ColumnType = ColumnType,
|
|
22
|
+
> = keyof T['selectable'] | RawExpression<C>;
|
|
23
|
+
|
|
24
|
+
export type ExpressionOfType<T extends Query, C extends ColumnType, Type> =
|
|
25
|
+
| {
|
|
26
|
+
[K in keyof T['selectable']]: ColumnOutput<
|
|
27
|
+
T['selectable'][K]['column']
|
|
28
|
+
> extends Type | null
|
|
29
|
+
? K
|
|
30
|
+
: never;
|
|
31
|
+
}[Selectable<T>]
|
|
32
|
+
| RawExpression<C>;
|
|
33
|
+
|
|
34
|
+
export type NumberExpression<
|
|
35
|
+
T extends Query,
|
|
36
|
+
C extends ColumnType = ColumnType,
|
|
37
|
+
> = ExpressionOfType<T, C, number>;
|
|
38
|
+
|
|
39
|
+
export type StringExpression<
|
|
40
|
+
T extends Query,
|
|
41
|
+
C extends ColumnType = ColumnType,
|
|
42
|
+
> = ExpressionOfType<T, C, string>;
|
|
43
|
+
|
|
44
|
+
export type BooleanExpression<
|
|
45
|
+
T extends Query,
|
|
46
|
+
C extends ColumnType = ColumnType,
|
|
47
|
+
> = ExpressionOfType<T, C, boolean>;
|
|
48
|
+
|
|
49
|
+
export type ExpressionOutput<
|
|
50
|
+
T extends Query,
|
|
51
|
+
Expr extends Expression<T>,
|
|
52
|
+
> = Expr extends keyof T['selectable']
|
|
53
|
+
? T['selectable'][Expr]['column']
|
|
54
|
+
: Expr extends RawExpression<infer ColumnType>
|
|
55
|
+
? ColumnType
|
|
56
|
+
: never;
|
|
57
|
+
|
|
58
|
+
export const raw = <C extends ColumnType>(sql: string, ...values: unknown[]) =>
|
|
59
|
+
({
|
|
60
|
+
__raw: sql,
|
|
61
|
+
__values: values,
|
|
62
|
+
} as RawExpression<C>);
|
|
63
|
+
|
|
64
|
+
export const rawColumn = <C extends ColumnType>(
|
|
65
|
+
column: C,
|
|
66
|
+
sql: string,
|
|
67
|
+
...values: unknown[]
|
|
68
|
+
) =>
|
|
69
|
+
({
|
|
70
|
+
__column: column,
|
|
71
|
+
__raw: sql,
|
|
72
|
+
__values: values,
|
|
73
|
+
} as RawExpression<C>);
|
|
74
|
+
|
|
75
|
+
export const isRaw = (obj: object): obj is RawExpression => '__raw' in obj;
|
|
76
|
+
|
|
77
|
+
export const getRaw = (raw: RawExpression, values: unknown[]) => {
|
|
78
|
+
values.push(...raw.__values);
|
|
79
|
+
return raw.__raw;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const EMPTY_OBJECT = {};
|
|
83
|
+
|
|
84
|
+
export const getQueryParsers = (q: Query) => {
|
|
85
|
+
return q.query.parsers || q.columnsParsers;
|
|
86
|
+
};
|
package/src/db.test.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adapter,
|
|
3
|
+
AssertEqual,
|
|
4
|
+
db,
|
|
5
|
+
expectSql,
|
|
6
|
+
User,
|
|
7
|
+
userData,
|
|
8
|
+
useTestDatabase,
|
|
9
|
+
} from './test-utils';
|
|
10
|
+
import { createDb } from './db';
|
|
11
|
+
import { columnTypes } from './columnSchema';
|
|
12
|
+
|
|
13
|
+
describe('db', () => {
|
|
14
|
+
useTestDatabase();
|
|
15
|
+
|
|
16
|
+
it('supports table without schema', () => {
|
|
17
|
+
const table = db('table');
|
|
18
|
+
const query = table.select('id', 'name').where({ foo: 'bar' });
|
|
19
|
+
expectSql(
|
|
20
|
+
query.toSql(),
|
|
21
|
+
`
|
|
22
|
+
SELECT "table"."id", "table"."name" FROM "table"
|
|
23
|
+
WHERE "table"."foo" = $1
|
|
24
|
+
`,
|
|
25
|
+
['bar'],
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('overriding column types', () => {
|
|
30
|
+
it('should return date as string by default', async () => {
|
|
31
|
+
await User.insert(userData);
|
|
32
|
+
|
|
33
|
+
const db = createDb({ adapter });
|
|
34
|
+
const table = db('user', (t) => ({
|
|
35
|
+
createdAt: t.timestamp(),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const result = await table.take().get('createdAt');
|
|
39
|
+
expect(typeof result).toBe('string');
|
|
40
|
+
|
|
41
|
+
const eq: AssertEqual<typeof result, string> = true;
|
|
42
|
+
expect(eq).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should return date as Date when overridden', async () => {
|
|
46
|
+
await User.insert(userData);
|
|
47
|
+
|
|
48
|
+
const db = createDb({
|
|
49
|
+
adapter,
|
|
50
|
+
columnTypes: {
|
|
51
|
+
timestamp() {
|
|
52
|
+
return columnTypes.timestamp().parse((input) => new Date(input));
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const table = db('user', (t) => ({
|
|
57
|
+
createdAt: t.timestamp(),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
const result = await table.take().get('createdAt');
|
|
61
|
+
expect(result instanceof Date).toBe(true);
|
|
62
|
+
|
|
63
|
+
const eq: AssertEqual<typeof result, Date> = true;
|
|
64
|
+
expect(eq).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
package/src/db.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColumnsParsers,
|
|
3
|
+
DefaultSelectColumns,
|
|
4
|
+
defaultsKey,
|
|
5
|
+
Query,
|
|
6
|
+
} from './query';
|
|
7
|
+
import { QueryMethods } from './queryMethods/queryMethods';
|
|
8
|
+
import { QueryData, SelectQueryData, Sql } from './sql';
|
|
9
|
+
import { AdapterOptions, Adapter } from './adapter';
|
|
10
|
+
import {
|
|
11
|
+
ColumnsShape,
|
|
12
|
+
columnTypes,
|
|
13
|
+
ColumnShapeOutput,
|
|
14
|
+
TableSchema,
|
|
15
|
+
AnyColumnTypeCreator,
|
|
16
|
+
ColumnShapeInput,
|
|
17
|
+
ColumnTypes,
|
|
18
|
+
} from './columnSchema';
|
|
19
|
+
import { applyMixins } from './utils';
|
|
20
|
+
import { StringKey } from './common';
|
|
21
|
+
import { handleResult, ThenResult } from './queryMethods/then';
|
|
22
|
+
import { WhereQueryBuilder } from './queryMethods/where';
|
|
23
|
+
import { OnQueryBuilder } from './queryMethods/join';
|
|
24
|
+
import { logParamToLogObject, QueryLogOptions } from './queryMethods/log';
|
|
25
|
+
|
|
26
|
+
export type DbTableOptions = {
|
|
27
|
+
schema?: string;
|
|
28
|
+
} & QueryLogOptions;
|
|
29
|
+
|
|
30
|
+
export interface Db<
|
|
31
|
+
Table extends string | undefined = undefined,
|
|
32
|
+
Shape extends ColumnsShape = Record<string, never>,
|
|
33
|
+
Relations extends Query['relations'] = Query['relations'],
|
|
34
|
+
> extends QueryMethods {
|
|
35
|
+
new (
|
|
36
|
+
adapter: Adapter,
|
|
37
|
+
queryBuilder: Db,
|
|
38
|
+
table?: Table,
|
|
39
|
+
shape?: Shape,
|
|
40
|
+
options?: DbTableOptions,
|
|
41
|
+
): this;
|
|
42
|
+
|
|
43
|
+
adapter: Adapter;
|
|
44
|
+
queryBuilder: Db;
|
|
45
|
+
whereQueryBuilder: Query['whereQueryBuilder'];
|
|
46
|
+
table: Table;
|
|
47
|
+
shape: Shape;
|
|
48
|
+
schema: TableSchema<Shape>;
|
|
49
|
+
type: ColumnShapeOutput<Shape>;
|
|
50
|
+
inputType: ColumnShapeInput<Shape>;
|
|
51
|
+
returnType: 'all';
|
|
52
|
+
then: ThenResult<
|
|
53
|
+
Pick<ColumnShapeOutput<Shape>, DefaultSelectColumns<Shape>[number]>[]
|
|
54
|
+
>;
|
|
55
|
+
query: QueryData;
|
|
56
|
+
columns: (keyof ColumnShapeOutput<Shape>)[];
|
|
57
|
+
defaultSelectColumns: DefaultSelectColumns<Shape>;
|
|
58
|
+
columnsParsers?: ColumnsParsers;
|
|
59
|
+
result: Pick<Shape, DefaultSelectColumns<Shape>[number]>;
|
|
60
|
+
hasSelect: false;
|
|
61
|
+
hasWhere: false;
|
|
62
|
+
selectable: { [K in keyof Shape]: { as: K; column: Shape[K] } } & {
|
|
63
|
+
[K in keyof Shape as `${Table}.${StringKey<K>}`]: {
|
|
64
|
+
as: K;
|
|
65
|
+
column: Shape[K];
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
tableAlias: undefined;
|
|
69
|
+
windows: PropertyKey[];
|
|
70
|
+
withData: Query['withData'];
|
|
71
|
+
joinedTables: Query['joinedTables'];
|
|
72
|
+
relations: Relations;
|
|
73
|
+
[defaultsKey]: Query[defaultsKey];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class Db<
|
|
77
|
+
Table extends string | undefined = undefined,
|
|
78
|
+
Shape extends ColumnsShape = Record<string, never>,
|
|
79
|
+
Relations extends Query['relations'] = Query['relations'],
|
|
80
|
+
> implements Query
|
|
81
|
+
{
|
|
82
|
+
whereQueryBuilder = WhereQueryBuilder;
|
|
83
|
+
onQueryBuilder = OnQueryBuilder;
|
|
84
|
+
|
|
85
|
+
constructor(
|
|
86
|
+
public adapter: Adapter,
|
|
87
|
+
public queryBuilder: Db,
|
|
88
|
+
public table: Table = undefined as Table,
|
|
89
|
+
public shape: Shape = {} as Shape,
|
|
90
|
+
options: DbTableOptions,
|
|
91
|
+
) {
|
|
92
|
+
this.__model = this;
|
|
93
|
+
|
|
94
|
+
const logger = options.logger || console;
|
|
95
|
+
this.query = {
|
|
96
|
+
adapter,
|
|
97
|
+
handleResult: handleResult,
|
|
98
|
+
returnType: 'all',
|
|
99
|
+
logger,
|
|
100
|
+
log: logParamToLogObject(logger, options.log),
|
|
101
|
+
} as QueryData;
|
|
102
|
+
|
|
103
|
+
if (options?.schema) {
|
|
104
|
+
this.query.schema = options.schema;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.schema = new TableSchema(shape);
|
|
108
|
+
const columns = Object.keys(
|
|
109
|
+
shape,
|
|
110
|
+
) as unknown as (keyof ColumnShapeOutput<Shape>)[];
|
|
111
|
+
const { toSql } = this;
|
|
112
|
+
|
|
113
|
+
this.columns = columns as (keyof ColumnShapeOutput<Shape>)[];
|
|
114
|
+
this.defaultSelectColumns = columns.filter(
|
|
115
|
+
(column) => !shape[column as keyof typeof shape].isHidden,
|
|
116
|
+
) as DefaultSelectColumns<Shape>;
|
|
117
|
+
|
|
118
|
+
const defaultSelect =
|
|
119
|
+
this.defaultSelectColumns.length === columns.length
|
|
120
|
+
? undefined
|
|
121
|
+
: this.defaultSelectColumns;
|
|
122
|
+
|
|
123
|
+
const columnsParsers: ColumnsParsers = {};
|
|
124
|
+
let hasParsers = false;
|
|
125
|
+
for (const key in shape) {
|
|
126
|
+
const column = shape[key];
|
|
127
|
+
if (column.parseFn) {
|
|
128
|
+
hasParsers = true;
|
|
129
|
+
columnsParsers[key] = column.parseFn;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.columnsParsers = hasParsers ? columnsParsers : undefined;
|
|
133
|
+
|
|
134
|
+
this.toSql = defaultSelect
|
|
135
|
+
? function <T extends Query>(this: T, values?: unknown[]): Sql {
|
|
136
|
+
const q = this.clone();
|
|
137
|
+
if (!(q.query as SelectQueryData).select) {
|
|
138
|
+
(q.query as SelectQueryData).select = defaultSelect as string[];
|
|
139
|
+
}
|
|
140
|
+
return toSql.call(q, values);
|
|
141
|
+
}
|
|
142
|
+
: toSql;
|
|
143
|
+
|
|
144
|
+
this.relations = {} as Relations;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
applyMixins(Db, [QueryMethods]);
|
|
149
|
+
Db.prototype.constructor = Db;
|
|
150
|
+
|
|
151
|
+
type DbResult<CT extends Record<string, AnyColumnTypeCreator>> = Db & {
|
|
152
|
+
<Table extends string, Shape extends ColumnsShape = ColumnsShape>(
|
|
153
|
+
table: Table,
|
|
154
|
+
shape?: ((t: CT) => Shape) | Shape,
|
|
155
|
+
options?: DbTableOptions,
|
|
156
|
+
): Db<Table, Shape>;
|
|
157
|
+
|
|
158
|
+
adapter: Adapter;
|
|
159
|
+
destroy: Adapter['destroy'];
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export type DbOptions<
|
|
163
|
+
CT extends Record<string, AnyColumnTypeCreator> = ColumnTypes,
|
|
164
|
+
> = ({ adapter: Adapter } | Omit<AdapterOptions, 'log'>) &
|
|
165
|
+
QueryLogOptions & {
|
|
166
|
+
columnTypes?: CT;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const createDb = <CT extends Record<string, AnyColumnTypeCreator>>({
|
|
170
|
+
log,
|
|
171
|
+
logger,
|
|
172
|
+
columnTypes: ct = columnTypes as unknown as CT,
|
|
173
|
+
...options
|
|
174
|
+
}: DbOptions<CT>): DbResult<CT> => {
|
|
175
|
+
const adapter = 'adapter' in options ? options.adapter : new Adapter(options);
|
|
176
|
+
const commonOptions = { log, logger };
|
|
177
|
+
|
|
178
|
+
const qb = new Db(
|
|
179
|
+
adapter,
|
|
180
|
+
undefined as unknown as Db,
|
|
181
|
+
undefined,
|
|
182
|
+
{},
|
|
183
|
+
commonOptions,
|
|
184
|
+
);
|
|
185
|
+
qb.queryBuilder = qb;
|
|
186
|
+
|
|
187
|
+
const db = Object.assign(
|
|
188
|
+
<Table extends string, Shape extends ColumnsShape = ColumnsShape>(
|
|
189
|
+
table: Table,
|
|
190
|
+
shape?: ((t: CT) => Shape) | Shape,
|
|
191
|
+
options?: DbTableOptions,
|
|
192
|
+
): Db<Table, Shape> => {
|
|
193
|
+
return new Db<Table, Shape>(
|
|
194
|
+
adapter,
|
|
195
|
+
qb,
|
|
196
|
+
table as Table,
|
|
197
|
+
typeof shape === 'function' ? shape(ct) : shape,
|
|
198
|
+
{ ...commonOptions, ...options },
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
qb,
|
|
202
|
+
{ adapter, destroy: () => adapter.destroy() },
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
// Set all methods from prototype to the db instance (needed for transaction at least):
|
|
206
|
+
Object.getOwnPropertyNames(Db.prototype).forEach((name) => {
|
|
207
|
+
(db as unknown as Record<string, unknown>)[name] =
|
|
208
|
+
Db.prototype[name as keyof typeof Db.prototype];
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return db as DbResult<CT>;
|
|
212
|
+
};
|
package/src/errors.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './columnSchema';
|
|
2
|
+
export * from './sql';
|
|
3
|
+
export * from './adapter';
|
|
4
|
+
export * from './common';
|
|
5
|
+
export * from './db';
|
|
6
|
+
export * from './operators';
|
|
7
|
+
export * from './query';
|
|
8
|
+
export * from './queryMethods/insert';
|
|
9
|
+
export * from './queryMethods/join';
|
|
10
|
+
export * from './queryMethods/transaction';
|
|
11
|
+
export * from './queryMethods/queryMethods';
|
|
12
|
+
export * from './queryMethods/columnInfo';
|
|
13
|
+
export * from './quote';
|
|
14
|
+
export * from './utils';
|
|
15
|
+
export * from './queryDataUtils';
|
|
16
|
+
export * from './queryMethods/then';
|
|
17
|
+
export * from './errors';
|
|
18
|
+
export * from './relations';
|