# Computed fields (Prisma ORM v6) (/docs/orm/v6/prisma-client/queries/computed-fields) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. This page explains how to use client extensions to add computed fields to Prisma models. Location: ORM > v6 > Prisma Client > Queries > Computed fields Computed fields allow you to derive a new field based on existing data. A common example is when you want to compute a full name. In your database, you may only store the first and last name, but you can define a function that computes a full name by combining the first and last name. Computed fields are read-only and stored in your application's memory, not in your database. ## Using a Prisma Client extension [#using-a-prisma-client-extension] The following example illustrates how to create a [Prisma Client extension](https://www.prisma.io/docs/orm/v6/prisma-client/client-extensions) that adds a `fullName` computed field at runtime to the `User` model in a Prisma schema. #### Prisma Client extension ```ts import { PrismaClient } from "../prisma/generated/client"; const prisma = new PrismaClient().$extends({ result: { user: { fullName: { needs: { firstName: true, lastName: true }, compute(user) { return `${user.firstName} ${user.lastName}`; }, }, }, }, }); async function main() { /** * Example query containing the `fullName` computed field in the response */ const user = await prisma.user.findFirst(); } main(); ``` ```js no-copy { id: 1, firstName: 'Aurelia', lastName: 'Schneider', email: 'Jalen_Berge40@hotmail.com', fullName: 'Aurelia Schneider', } ``` #### Prisma schema ```prisma copy datasource db { provider = "postgresql" } generator client { provider = "prisma-client" output = "./generated" } model User { id Int @id @default(autoincrement()) email String @unique firstName String lastName String posts Post[] } model Post { id Int @id @default(autoincrement()) title String published Boolean @default(true) content String? authorId Int? author User? @relation(fields: [authorId], references: [id]) } ``` The computed fields are type-safe and can return anything from a concatenated value to complex objects or functions that can act as an instance method for your models. **Instructions prior to Prisma ORM 4.16.0** > [!WARNING] > With Prisma Client extensions Generally Available as of Prisma ORM version 4.16.0, the following steps are not recommended. Please use [a client extension](#using-a-prisma-client-extension) to accomplish this. Prisma Client does not yet natively support computed fields, but, you can define a function that accepts a generic type as an input then extend that generic to ensure it conforms to a specific structure. Finally, you can return that generic with additional computed fields. The following example shows this approach: #### TypeScript ```tsx // Define a type that needs a first and last name type FirstLastName = { firstName: string; lastName: string; }; // Extend the T generic with the fullName attribute type WithFullName = T & { fullName: string; }; // Take objects that satisfy FirstLastName and computes a full name function computeFullName(user: User): WithFullName { return { ...user, fullName: user.firstName + " " + user.lastName, }; } async function main() { const user = await prisma.user.findUnique({ where: 1 }); const userWithFullName = computeFullName(user); } ``` #### JavaScript ```js function computeFullName(user) { return { ...user, fullName: user.firstName + " " + user.lastName, }; } async function main() { const user = await prisma.user.findUnique({ where: 1 }); const userWithFullName = computeFullName(user); } ``` In the TypeScript example above, a `User` generic has been defined that extends the `FirstLastName` type. This means that whatever you pass into `computeFullName` must contain `firstName` and `lastName` keys. A `WithFullName` return type has also been defined, which takes whatever `User` is and tacks on a `fullName` string attribute. With this function, any object that contains `firstName` and `lastName` keys can compute a `fullName`. ### Going further [#going-further] * Learn how you can use [Prisma Client extensions](https://www.prisma.io/docs/orm/v6/prisma-client/client-extensions) to add a computed field to your schema — [example](https://github.com/prisma/prisma-client-extensions/tree/main/computed-fields). * Learn how you can move the `computeFullName` function into [a custom model](https://www.prisma.io/docs/orm/v6/prisma-client/queries/custom-models). * There's an [open feature request](https://github.com/prisma/orm/issues/3394) to add native support to Prisma Client. If you'd like to see that happen, make sure to upvote that issue and share your use case! ## Related pages - [`Aggregation, grouping, and summarizing`](https://www.prisma.io/docs/orm/v6/prisma-client/queries/aggregation-grouping-summarizing): Use Prisma Client to aggregate, group by, count, and select distinct. - [`Case sensitivity`](https://www.prisma.io/docs/orm/v6/prisma-client/queries/case-sensitivity): How Prisma Client handles case sensitivity when filtering and sorting. - [`CRUD`](https://www.prisma.io/docs/orm/v6/prisma-client/queries/crud): How to perform CRUD with Prisma Client. - [`Custom models`](https://www.prisma.io/docs/orm/v6/prisma-client/queries/custom-models): This page explains how to wrap Prisma Client in custom models - [`Custom validation`](https://www.prisma.io/docs/orm/v6/prisma-client/queries/custom-validation): This page explains how to add custom validation to Prisma Client