This example shows how to use a Prisma Client extension to transform result fields returned by queries. In this example, a date field is transformed to a relative string for a specific locale.
This example shows a way to implement internationalization (i18n) at the data access layer in your application. However, this technique allows you to implement any kind of custom transformation or serialization/deserialization of fields on your query results.
This extension is provided as an example only. It is not intended to be used in production environments.
Please read the documentation on result
extensions for more information.
- Install Node.js
Clone this repository:
git clone [email protected]:sbking/prisma-client-extensions.git
Install dependencies:
cd transformed-fields
npm install
Run the following command. An SQLite database will be created automatically:
npx prisma migrate deploy
Run the following command to add seed data to the database:
npx prisma db seed
To run the script.ts
file, run the following command:
npm run dev