pqb 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pqb",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Postgres query builder",
5
5
  "homepage": "https://porm.netlify.app/guide/query-builder.html",
6
6
  "repository": {
@@ -44,7 +44,7 @@ export class ColumnInfoMethods {
44
44
  (this.query as ColumnInfoQueryData).column = column as string;
45
45
  }
46
46
 
47
- this.then = function (resolve, reject) {
47
+ this.then = function (this: Query, resolve, reject) {
48
48
  new Then().then.call(
49
49
  this,
50
50
  (rows) => {
@@ -177,7 +177,7 @@ const _join = <
177
177
 
178
178
  const relation = (q.relations as Record<string, Relation>)[joinKey];
179
179
  if (relation) {
180
- parsers = relation.model.query.parsers || relation.model.columnsParsers;
180
+ parsers = relation.query.query.parsers || relation.query.columnsParsers;
181
181
  } else {
182
182
  const shape = q.query.withShapes?.[first as string];
183
183
  if (shape) {
@@ -6,8 +6,7 @@ import { CommonQueryData, Sql } from '../sql';
6
6
  import { AfterCallback, BeforeCallback } from './callbacks';
7
7
  import { getValueKey } from './get';
8
8
 
9
- export type ThenResult<Res> = <T extends Query>(
10
- this: T,
9
+ export type ThenResult<Res> = (
11
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
11
  resolve?: (value: Res) => any,
13
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1546,14 +1546,14 @@ export const testJoin = (
1546
1546
  describe('relation', () => {
1547
1547
  const withRelation = q as Query & {
1548
1548
  relations: {
1549
- message: { key: 'message'; model: typeof Message; joinQuery: Query };
1549
+ message: { key: 'message'; query: typeof Message; joinQuery: Query };
1550
1550
  };
1551
1551
  };
1552
1552
 
1553
1553
  withRelation.relations = {
1554
1554
  message: {
1555
1555
  key: 'message',
1556
- model: Message,
1556
+ query: Message,
1557
1557
  joinQuery: pushQueryOn(Message.clone(), Message, q, 'authorId', 'id'),
1558
1558
  },
1559
1559
  };
package/src/relations.ts CHANGED
@@ -91,6 +91,7 @@ export type BaseRelation = {
91
91
  type: string;
92
92
  key: string;
93
93
  model: QueryWithTable;
94
+ query: QueryWithTable;
94
95
  joinQuery: Query;
95
96
  nestedCreateQuery: Query;
96
97
  nestedInsert?: