标签: nexus-js

Nexus Prisma - 如何在全局范围内使用 crud 处理 createdAt 和 updatedAt?

我想出了第一件事情,就是通过调用computedInputsnexusPrisma选项。但它不会起作用,因为它们需要根据情况进行不同的处理,但在全局范围内:

1. create -> createdAt = now, updatedAt = null
2. update -> createdAt = keep as it is, updatedAt = now
Run Code Online (Sandbox Code Playgroud)

为了使其工作,我需要像这样单独设置计算输入:

1. create -> createdAt = now, updatedAt = null
2. update -> createdAt = keep as it is, updatedAt = now
Run Code Online (Sandbox Code Playgroud)

虽然这可能有效,但我无法在嵌套模型上“计算”这些输入。为了防止传递 createdAt/updatedAt,我还必须t.crud在该资源上创建另一个,没有这些时间戳。

最后一个可能有效的解决方法是根本不使用t.crud,这是一个无赖。

typescript prisma nexus-js

2
推荐指数
1
解决办法
2637
查看次数

标签 统计

nexus-js ×1

prisma ×1

typescript ×1