@twin.org/entity-storage-connector-postgresql 0.10.1-next.5 → 0.10.1-next.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.
@@ -1,7 +1,7 @@
1
1
  import { type IHealth, type IHealthProviderComponent } from "@twin.org/api-models";
2
2
  import { type IContextIds } from "@twin.org/context";
3
3
  import { type EntityCondition, type IEntitySchema, SortDirection } from "@twin.org/entity";
4
- import { type IEntityStorageMigrationConnector, type IMigrationOptions } from "@twin.org/entity-storage-models";
4
+ import { type IEntityStorageConnector, type IEntityStorageJoinOptions, type IEntityStorageMigrationConnector, type IMigrationOptions } from "@twin.org/entity-storage-models";
5
5
  import type { IPostgreSqlEntityStorageConnectorConstructorOptions } from "./models/IPostgreSqlEntityStorageConnectorConstructorOptions.js";
6
6
  /**
7
7
  * Class for performing entity storage operations using ql.
@@ -146,6 +146,27 @@ export declare class PostgreSqlEntityStorageConnector<T = unknown> implements IE
146
146
  entities: Partial<T>[];
147
147
  cursor?: string;
148
148
  }>;
149
+ /**
150
+ * Find all the entities which match the conditions, attaching to each one the entities from a
151
+ * second storage connector whose join property matches. The join behaves like a left join by
152
+ * default, a primary entity with no matches is still returned with an empty joined list, unless
153
+ * joinRequired asks for an inner join and those entities are left out altogether. Both connectors
154
+ * must be PostgreSQL connectors reading from the same database so the work can be done in a
155
+ * single statement.
156
+ * @param joinConnector The connector holding the entities to join to.
157
+ * @param joinOptions The properties to join on, the conditions, sort order, projection and
158
+ * paging for the primary entities, the optional grouping and group conditions, and the optional
159
+ * conditions, sort order and projection for the joined entities.
160
+ * @returns All the entities for the storage matching the conditions with their joined entities,
161
+ * and a cursor which can be used to request more entities.
162
+ * @throws GeneralError if the join connector does not read from the same server and database.
163
+ */
164
+ queryJoin<U>(joinConnector: IEntityStorageConnector<U>, joinOptions: IEntityStorageJoinOptions<T, U>): Promise<{
165
+ entities: (Partial<T> & {
166
+ joined: Partial<U>[];
167
+ })[];
168
+ cursor?: string;
169
+ }>;
149
170
  /**
150
171
  * Count all the entities which match the conditions.
151
172
  * @param conditions The optional conditions to match for the entities.
package/docs/changelog.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.10.1-next.7](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.6...entity-storage-connector-postgresql-v0.10.1-next.7) (2026-09-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * project properties in common group join ([b90389d](https://github.com/iotaledger/twin-entity-storage/commit/b90389dd7df593b560faf2299e912c25a66bf6ee))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.6 to 0.10.1-next.7
16
+ * devDependencies
17
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.6 to 0.10.1-next.7
18
+
19
+ ## [0.10.1-next.6](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.5...entity-storage-connector-postgresql-v0.10.1-next.6) (2026-09-21)
20
+
21
+
22
+ ### Features
23
+
24
+ * join and group ([#295](https://github.com/iotaledger/twin-entity-storage/issues/295)) ([e0103b3](https://github.com/iotaledger/twin-entity-storage/commit/e0103b3af5d9d0d37d4f590c6f31993d2c7e6508))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.5 to 0.10.1-next.6
32
+ * devDependencies
33
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.5 to 0.10.1-next.6
34
+
3
35
  ## [0.10.1-next.5](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.4...entity-storage-connector-postgresql-v0.10.1-next.5) (2026-09-18)
4
36
 
5
37
 
@@ -556,6 +556,56 @@ and a cursor which can be used to request more entities.
556
556
 
557
557
  ***
558
558
 
559
+ ### queryJoin() {#queryjoin}
560
+
561
+ > **queryJoin**\<`U`\>(`joinConnector`, `joinOptions`): `Promise`\<\{ `entities`: `Partial`\<`T`\> & `object`[]; `cursor?`: `string`; \}\>
562
+
563
+ Find all the entities which match the conditions, attaching to each one the entities from a
564
+ second storage connector whose join property matches. The join behaves like a left join by
565
+ default, a primary entity with no matches is still returned with an empty joined list, unless
566
+ joinRequired asks for an inner join and those entities are left out altogether. Both connectors
567
+ must be PostgreSQL connectors reading from the same database so the work can be done in a
568
+ single statement.
569
+
570
+ #### Type Parameters
571
+
572
+ ##### U
573
+
574
+ `U`
575
+
576
+ #### Parameters
577
+
578
+ ##### joinConnector
579
+
580
+ `IEntityStorageConnector`\<`U`\>
581
+
582
+ The connector holding the entities to join to.
583
+
584
+ ##### joinOptions
585
+
586
+ `IEntityStorageJoinOptions`\<`T`, `U`\>
587
+
588
+ The properties to join on, the conditions, sort order, projection and
589
+ paging for the primary entities, the optional grouping and group conditions, and the optional
590
+ conditions, sort order and projection for the joined entities.
591
+
592
+ #### Returns
593
+
594
+ `Promise`\<\{ `entities`: `Partial`\<`T`\> & `object`[]; `cursor?`: `string`; \}\>
595
+
596
+ All the entities for the storage matching the conditions with their joined entities,
597
+ and a cursor which can be used to request more entities.
598
+
599
+ #### Throws
600
+
601
+ GeneralError if the join connector does not read from the same server and database.
602
+
603
+ #### Implementation of
604
+
605
+ `IEntityStorageMigrationConnector.queryJoin`
606
+
607
+ ***
608
+
559
609
  ### count() {#count}
560
610
 
561
611
  > **count**(`conditions?`): `Promise`\<`number`\>
package/locales/en.json CHANGED
@@ -25,6 +25,8 @@
25
25
  "getFailed": "Unable to get entity \"{id}\"",
26
26
  "removeFailed": "Unable to remove entity \"{id}\"",
27
27
  "queryFailed": "The query failed",
28
+ "queryJoinFailed": "The join query failed",
29
+ "joinConnectorMismatch": "The join connector must be a PostgreSQL connector reading from the same server and database \"{database}\"",
28
30
  "comparisonNotSupported": "Comparison operator \"{comparison}\" is not supported",
29
31
  "conditionalNotSupported": "Conditional operator \"{operator}\" is not supported",
30
32
  "entitySchemaPropertiesUndefined": "The entity schema properties are undefined",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-postgresql",
3
- "version": "0.10.1-next.5",
3
+ "version": "0.10.1-next.7",
4
4
  "description": "PostgreSQL connector for relational persistence and advanced SQL features.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/entity": "next",
21
- "@twin.org/entity-storage-models": "0.10.1-next.5",
21
+ "@twin.org/entity-storage-models": "0.10.1-next.7",
22
22
  "@twin.org/logging-models": "next",
23
23
  "@twin.org/nameof": "next",
24
24
  "postgres": "3.4.9"