Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 705c7a9

Browse files
committed
fix(proxy): add omit configuration for computed fields in ZenStackClient
1 parent a70a1cb commit 705c7a9

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

packages/cli/src/actions/proxy.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Pool as PgPool } from 'pg';
2424
import { CliError } from '../cli-error';
2525
import { getVersion } from '../utils/version-utils';
2626
import { getOutputPath, getSchemaFile, loadSchemaDocument } from './action-utils';
27+
import type { ModelDef, SchemaDef, SchemaDef } from '@zenstackhq/orm/schema';
2728

2829
type Options = {
2930
output?: string;
@@ -72,9 +73,25 @@ export async function run(options: Options) {
7273

7374
const schemaModule = (await jiti.import(path.join(outputPath, 'schema'))) as any;
7475

75-
const db = new ZenStackClient(schemaModule.schema, {
76+
// Build omit configuration for computed fields
77+
const schema = schemaModule.schema as SchemaDef;
78+
const omit: Record<string, Record<string, boolean>> = {};
79+
for (const [modelName, modelDef] of Object.entries(schema.models)) {
80+
const computedFields: Record<string, boolean> = {};
81+
for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) {
82+
if (fieldDef.computed === true) {
83+
computedFields[fieldName] = true;
84+
}
85+
}
86+
if (Object.keys(computedFields).length > 0) {
87+
omit[modelName] = computedFields;
88+
}
89+
}
90+
91+
const db = new ZenStackClient(schema, {
7692
dialect: dialect,
7793
log: log && log.length > 0 ? log : undefined,
94+
omit: Object.keys(omit).length > 0 ? omit : undefined,
7895
});
7996

8097
// check whether the database is reachable

0 commit comments

Comments
 (0)