sql-typechecker 0.0.38 → 0.0.43
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/out/cli.js +5 -2
- package/out/cli.js.map +2 -2
- package/package.json +1 -1
package/out/cli.js
CHANGED
|
@@ -243490,12 +243490,15 @@ import type { Pool } from "pg";
|
|
|
243490
243490
|
import { Instant, LocalDate, LocalTime, LocalDateTime} from "@js-joda/core";
|
|
243491
243491
|
`;
|
|
243492
243492
|
}
|
|
243493
|
+
function genSelectColumnsFromTable(t) {
|
|
243494
|
+
return t.fields.map((f) => f.name?.name || "?").join(", ");
|
|
243495
|
+
}
|
|
243493
243496
|
function genCrudOperations(table) {
|
|
243494
243497
|
const selectAll = `
|
|
243495
243498
|
export async function getAll(pool: Pool): Promise<${showTypeAsTypescriptType(table.rel)}[]>{
|
|
243496
243499
|
|
|
243497
243500
|
const res = await pool.query({
|
|
243498
|
-
text: "SELECT
|
|
243501
|
+
text: "SELECT ${genSelectColumnsFromTable(table.rel)} FROM ${showQName(table.name)}",
|
|
243499
243502
|
values: [],
|
|
243500
243503
|
rowMode: "array",
|
|
243501
243504
|
});
|
|
@@ -243541,7 +243544,7 @@ export async function insert(pool: Pool, row: {${inputRow}}): Promise<{${primary
|
|
|
243541
243544
|
export async function getOne(pool: Pool, pk: {${primaryKeySingleCol.name.name}: ${showTypeAsTypescriptType(primaryKeySingleCol.type)}}): Promise<${showTypeAsTypescriptType(table.rel)} | null>{
|
|
243542
243545
|
|
|
243543
243546
|
const res = await pool.query({
|
|
243544
|
-
text: "SELECT
|
|
243547
|
+
text: "SELECT ${genSelectColumnsFromTable(table.rel)} FROM ${showQName(table.name)} WHERE ${primaryKeySingleCol.name.name} = $1",
|
|
243545
243548
|
values: [pk.${primaryKeySingleCol.name.name}] as any[],
|
|
243546
243549
|
rowMode: "array",
|
|
243547
243550
|
});
|