postgresdk 0.7.4 → 0.7.6
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/cli.js +14 -2
- package/dist/index.js +14 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1668,7 +1668,15 @@ function emitZod(table, opts) {
|
|
|
1668
1668
|
return `z.array(${zFor(pg.slice(1))})`;
|
|
1669
1669
|
return `z.string()`;
|
|
1670
1670
|
};
|
|
1671
|
-
const
|
|
1671
|
+
const selectFields = table.columns.map((c) => {
|
|
1672
|
+
let z = zFor(c.pgType);
|
|
1673
|
+
if (c.nullable) {
|
|
1674
|
+
z += `.nullable()`;
|
|
1675
|
+
}
|
|
1676
|
+
return ` ${c.name}: ${z}`;
|
|
1677
|
+
}).join(`,
|
|
1678
|
+
`);
|
|
1679
|
+
const insertFields = table.columns.map((c) => {
|
|
1672
1680
|
let z = zFor(c.pgType);
|
|
1673
1681
|
if (c.nullable) {
|
|
1674
1682
|
z += `.nullish()`;
|
|
@@ -1680,8 +1688,12 @@ function emitZod(table, opts) {
|
|
|
1680
1688
|
`);
|
|
1681
1689
|
return `import { z } from "zod";
|
|
1682
1690
|
|
|
1691
|
+
export const Select${Type}Schema = z.object({
|
|
1692
|
+
${selectFields}
|
|
1693
|
+
});
|
|
1694
|
+
|
|
1683
1695
|
export const Insert${Type}Schema = z.object({
|
|
1684
|
-
${
|
|
1696
|
+
${insertFields}
|
|
1685
1697
|
});
|
|
1686
1698
|
|
|
1687
1699
|
export const Update${Type}Schema = Insert${Type}Schema.partial();
|
package/dist/index.js
CHANGED
|
@@ -1405,7 +1405,15 @@ function emitZod(table, opts) {
|
|
|
1405
1405
|
return `z.array(${zFor(pg.slice(1))})`;
|
|
1406
1406
|
return `z.string()`;
|
|
1407
1407
|
};
|
|
1408
|
-
const
|
|
1408
|
+
const selectFields = table.columns.map((c) => {
|
|
1409
|
+
let z = zFor(c.pgType);
|
|
1410
|
+
if (c.nullable) {
|
|
1411
|
+
z += `.nullable()`;
|
|
1412
|
+
}
|
|
1413
|
+
return ` ${c.name}: ${z}`;
|
|
1414
|
+
}).join(`,
|
|
1415
|
+
`);
|
|
1416
|
+
const insertFields = table.columns.map((c) => {
|
|
1409
1417
|
let z = zFor(c.pgType);
|
|
1410
1418
|
if (c.nullable) {
|
|
1411
1419
|
z += `.nullish()`;
|
|
@@ -1417,8 +1425,12 @@ function emitZod(table, opts) {
|
|
|
1417
1425
|
`);
|
|
1418
1426
|
return `import { z } from "zod";
|
|
1419
1427
|
|
|
1428
|
+
export const Select${Type}Schema = z.object({
|
|
1429
|
+
${selectFields}
|
|
1430
|
+
});
|
|
1431
|
+
|
|
1420
1432
|
export const Insert${Type}Schema = z.object({
|
|
1421
|
-
${
|
|
1433
|
+
${insertFields}
|
|
1422
1434
|
});
|
|
1423
1435
|
|
|
1424
1436
|
export const Update${Type}Schema = Insert${Type}Schema.partial();
|