diff --git a/package.json b/package.json index 53235de4..87a0d345 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kirimase", - "version": "0.0.51", + "version": "0.0.52", "description": "A Rails-like CLI for building full-stack Next.js apps faster", "main": "index.js", "type": "module", diff --git a/src/commands/generate/generators/model/queries/generators.ts b/src/commands/generate/generators/model/queries/generators.ts index 0e658927..50dd0215 100644 --- a/src/commands/generate/generators/model/queries/generators.ts +++ b/src/commands/generate/generators/model/queries/generators.ts @@ -193,6 +193,7 @@ const generateDrizzleGetByIdQuery = (schema: Schema, relations: DBField[]) => { .join("") : "" }; + if (row === undefined) return {}; const ${tableNameFirstChar} = ${ relations.length > 0 ? ` { ...row.${tableNameSingular}, ${relations @@ -257,6 +258,7 @@ const generateDrizzleGetByIdWithChildrenQuery = ( .join("") : "" }; + if (rows.length === 0) return {}; const ${tableNameFirstChar} = rows[0].${tableNameSingular}; ${ children.length > 0 diff --git a/src/index.ts b/src/index.ts index 1785b474..b35b159d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import { buildSchema } from "./commands/generate/index.js"; import { addPackage } from "./commands/add/index.js"; const program = new Command(); -program.name("kirimase").description("Kirimase CLI").version("0.0.51"); +program.name("kirimase").description("Kirimase CLI").version("0.0.52"); addCommonOptions(program.command("init")) .description("initialise and configure kirimase within directory")