我想出了第一件事情,就是通过调用computedInputs的nexusPrisma选项。但它不会起作用,因为它们需要根据情况进行不同的处理,但在全局范围内:
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,这是一个无赖。