chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
578 stars 43 forks source link

Implemented on #256 UpdateOperationsInput Type Generation Disabled #257

Open StringKe opened 1 month ago

StringKe commented 1 month ago

The types of SomeUpdateArgsSchema do not use the where condition of methods such as find.

    update: adminProcedure.input(ProductAttributeUpdateArgsSchema).mutation(async ({ input }) => {
        const database = getDatabase();

        if (!input.where.id) {
            throw BusinessError.fromCode('ID_NOT_FOUND');
        }

        const data = await database.productAttribute.findUnique({
            where: {
                id: input.where.id, // SomeUpdateArgsSchema not worker this
            },
        });

        if (!data) {
            throw BusinessError.fromCode('ID_NOT_FOUND');
        }

        return database.productAttribute.update({
            where: {
                id: input.where.id,
            },
            data: input.data,
        });
    }),