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 [email protected]:sbking/prisma-client-extensions.git
Install dependencies:
cd instance-methods
npm install
Run the following command. An SQLite database will be created automatically:
npx prisma migrate deploy
To run the script.ts
file, run the following command:
npm run dev