MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / makeOmitSchema

Method makeOmitSchema

packages/orm/src/client/zod/factory.ts:1289–1308  ·  view source on GitHub ↗
(model: string)

Source from the content-addressed store, hash-verified

1287
1288 @cache()
1289 private makeOmitSchema(model: string) {
1290 const fields: Record<string, ZodType> = {};
1291 for (const [field, fieldDef] of this.getModelFields(model)) {
1292 if (!fieldDef.relation) {
1293 if (this.options.allowQueryTimeOmitOverride !== false) {
1294 // if override is allowed, use boolean
1295 fields[field] = z.boolean().optional();
1296 } else {
1297 // otherwise only allow true
1298 fields[field] = z.literal(true).optional();
1299 }
1300 }
1301 }
1302
1303 this.addExtResultFields(model, fields);
1304
1305 const result = z.strictObject(fields);
1306 this.registerSchema(`${model}OmitInput`, result);
1307 return result;
1308 }
1309
1310 private addExtResultFields(model: string, fields: Record<string, ZodType>) {
1311 for (const plugin of this.plugins) {

Callers 8

makeFindSchemaMethod · 0.95
makeCreateSchemaMethod · 0.95
makeUpdateSchemaMethod · 0.95
makeUpsertSchemaMethod · 0.95
makeDeleteSchemaMethod · 0.95

Calls 3

getModelFieldsMethod · 0.95
addExtResultFieldsMethod · 0.95
registerSchemaMethod · 0.95

Tested by

no test coverage detected