orchid-orm 1.72.8 → 1.72.9
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 +13 -0
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -10
- package/dist/index.mjs.map +1 -1
- package/dist/migrations/index.js +44 -4
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +45 -5
- package/dist/migrations/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -562,9 +562,15 @@ interface ORMTableInput extends PickORMTableInputColumnsAndComputed {
|
|
|
562
562
|
grants?: readonly Grant.TableClassGrant[];
|
|
563
563
|
readonly readOnly?: boolean;
|
|
564
564
|
readonly materialized?: true;
|
|
565
|
+
/**
|
|
566
|
+
* Keep this table-like definition available at runtime, but exclude it from
|
|
567
|
+
* generated migration DDL reconciliation.
|
|
568
|
+
*/
|
|
569
|
+
generatorIgnore?: true;
|
|
565
570
|
table?: string;
|
|
566
571
|
noPrimaryKey?: boolean;
|
|
567
572
|
name?: string;
|
|
573
|
+
query?: Query;
|
|
568
574
|
sql?: string | RawSqlBase;
|
|
569
575
|
recursive?: boolean;
|
|
570
576
|
checkOption?: 'LOCAL' | 'CASCADED';
|
|
@@ -610,6 +616,11 @@ interface BaseTableInstance<ColumnTypes> {
|
|
|
610
616
|
q: QueryData;
|
|
611
617
|
language?: string;
|
|
612
618
|
filePath: string;
|
|
619
|
+
/**
|
|
620
|
+
* Keep this table-like definition available at runtime, but exclude it from
|
|
621
|
+
* generated migration DDL reconciliation.
|
|
622
|
+
*/
|
|
623
|
+
generatorIgnore?: true;
|
|
613
624
|
result: Column.Shape.QueryInit;
|
|
614
625
|
clone<T extends IsQuery>(this: T): T;
|
|
615
626
|
getFilePath(): string;
|
|
@@ -819,6 +830,7 @@ interface BaseTableClass<SchemaConfig extends ColumnSchemaConfig, ColumnTypes> {
|
|
|
819
830
|
}
|
|
820
831
|
interface BaseViewInstance<ColumnTypes> extends BaseTableInstance<ColumnTypes> {
|
|
821
832
|
name: string;
|
|
833
|
+
query?: Query;
|
|
822
834
|
sql: string | RawSqlBase;
|
|
823
835
|
readonly readOnly?: boolean;
|
|
824
836
|
recursive?: boolean;
|
|
@@ -828,6 +840,7 @@ interface BaseViewInstance<ColumnTypes> extends BaseTableInstance<ColumnTypes> {
|
|
|
828
840
|
}
|
|
829
841
|
interface BaseMaterializedViewInstance<ColumnTypes> extends BaseTableInstance<ColumnTypes> {
|
|
830
842
|
name: string;
|
|
843
|
+
query?: Query;
|
|
831
844
|
sql: string | RawSqlBase;
|
|
832
845
|
readonly readOnly?: true;
|
|
833
846
|
readonly materialized: true;
|
package/dist/index.js
CHANGED
|
@@ -1482,18 +1482,12 @@ const assignTablesToOrm = (isTable, tables, result, adapter, qb, asyncStorage, c
|
|
|
1482
1482
|
comment: table.comment,
|
|
1483
1483
|
readOnly: isTable ? table.readOnly ? true : void 0 : table.materialized || table.readOnly !== false ? true : void 0,
|
|
1484
1484
|
materialized: !isTable && table.materialized ? true : void 0,
|
|
1485
|
+
generatorIgnore: table.generatorIgnore,
|
|
1485
1486
|
noPrimaryKey: table.noPrimaryKey || !isTable ? "ignore" : void 0,
|
|
1486
1487
|
computed: table.computed,
|
|
1487
1488
|
nowSQL: tableClass.nowSQL
|
|
1488
1489
|
};
|
|
1489
|
-
const dbTable = new pqb.Db(adapter, qb, isTable ? table.table : table.name, table.columns.shape, table.types, asyncStorage, options, table.columns?.data ?? {}, isTable
|
|
1490
|
-
sql: table.sql,
|
|
1491
|
-
recursive: table.recursive,
|
|
1492
|
-
checkOption: table.checkOption,
|
|
1493
|
-
securityBarrier: table.securityBarrier,
|
|
1494
|
-
securityInvoker: table.securityInvoker,
|
|
1495
|
-
withData: table.withData
|
|
1496
|
-
});
|
|
1490
|
+
const dbTable = new pqb.Db(adapter, qb, isTable ? table.table : table.name, table.columns.shape, table.types, asyncStorage, options, table.columns?.data ?? {}, getViewData(isTable, table));
|
|
1497
1491
|
dbTable.definedAs = key;
|
|
1498
1492
|
dbTable.db = result;
|
|
1499
1493
|
dbTable.filePath = table.filePath;
|
|
@@ -1504,6 +1498,18 @@ const assignTablesToOrm = (isTable, tables, result, adapter, qb, asyncStorage, c
|
|
|
1504
1498
|
}
|
|
1505
1499
|
return tableInstances;
|
|
1506
1500
|
};
|
|
1501
|
+
const getViewData = (isTable, table) => {
|
|
1502
|
+
if (isTable) return;
|
|
1503
|
+
return {
|
|
1504
|
+
query: table.query,
|
|
1505
|
+
sql: table.sql,
|
|
1506
|
+
recursive: table.recursive,
|
|
1507
|
+
checkOption: table.checkOption,
|
|
1508
|
+
securityBarrier: table.securityBarrier,
|
|
1509
|
+
securityInvoker: table.securityInvoker,
|
|
1510
|
+
withData: table.withData
|
|
1511
|
+
};
|
|
1512
|
+
};
|
|
1507
1513
|
const bundleOrchidORM = ({ tables = {}, views = {} }) => {
|
|
1508
1514
|
const result = {};
|
|
1509
1515
|
const bundledViews = {};
|
|
@@ -1619,14 +1625,23 @@ const privateOrchidORMWithAdapter = ({ log, logger, autoPreparedStatements, noPr
|
|
|
1619
1625
|
...result.$views
|
|
1620
1626
|
}, schema);
|
|
1621
1627
|
setDbAwareInstance?.(result);
|
|
1622
|
-
const initItems = [[
|
|
1623
|
-
|
|
1628
|
+
const initItems = [[
|
|
1629
|
+
tableInstances,
|
|
1630
|
+
result,
|
|
1631
|
+
true
|
|
1632
|
+
], [
|
|
1633
|
+
viewInstances,
|
|
1634
|
+
result.$views,
|
|
1635
|
+
false
|
|
1636
|
+
]];
|
|
1637
|
+
for (const [items, queries, isTable] of initItems) {
|
|
1624
1638
|
if (!items) continue;
|
|
1625
1639
|
for (const key in items) {
|
|
1626
1640
|
const table = items[key];
|
|
1627
1641
|
if (table.init) {
|
|
1628
1642
|
table.init(result);
|
|
1629
1643
|
Object.assign(queries[key].baseQuery.q, table.q);
|
|
1644
|
+
if (!isTable) queries[key].internal.viewData = getViewData(false, table);
|
|
1630
1645
|
}
|
|
1631
1646
|
}
|
|
1632
1647
|
}
|