Is there any way to declare a calculated field on ...
# orm-help
y
Is there any way to declare a calculated field on a model? Example of what I'd like to do:
Copy code
model User {
  id         Int    @id @default(autoincrement())
  first_name String
  last_name  String
  full_name  String @calculated({first_name} + {last_name})
}
If not, is there any recommended convention for doing this?
a
Prisma doesn't do that within the model
it's kinda left up to you/your framework
Copy code
const user = await prisma.User.findFirst();
user.fullName = `${user.firstName} ${user.lastName}`;
is a simple example
if you're on typescript you'll need to extend the model
y
Thanks!