This example shows how to add an Active Record-like interface to Prisma result objects. It uses a result extension to add save and delete methods directly to User model objects returned by Prisma Client methods.
This technique can be used to customize Prisma result objects with behavior, analogous to adding instance methods to model classes.
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 git@github.com:sbking/prisma-client-extensions.gitInstall dependencies:
cd instance-methods
npm installRun the following command. An SQLite database will be created automatically:
npx prisma migrate deployTo run the script.ts file, run the following command:
npm run dev