Skip to content

Cannot read properties of undefined (reading 'aggregate') #1406

@NatoBoram

Description

@NatoBoram

Description and expected behavior

When using the trpc plugin, there's table files generated at routers/<table_name>.ts. Let's take a table api_key_org.

export default function createRouter<Config extends BaseConfig>(
	router: RouterFactory<Config>,
	procedure: ProcBuilder<Config>,
) {
	return router({
		aggregate: procedure
			.input($Schema.Api_key_orgInputSchema.aggregate)
			.query(({ ctx, input }) =>
				checkRead(db(ctx).api_key_org.aggregate(input as any)),
			),

This outputs an error:

TypeError: Cannot read properties of undefined (reading 'aggregate')

If we log $Schema, we get this:

[Module: null prototype] {
  default: {
    Api_key_orgInputSchema: {

So $Schema.Api_key_orgInputSchema.aggregate is actually at $Schema.default.Api_key_orgInputSchema.aggregate.

Screenshots

Environment (please complete the following information):

  • ZenStack version: "2.0.2"
  • Prisma version: "5.13.0"
  • Database type: Postgresql

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions