Skip to content

Latest commit

 

History

History
 
 

instance-methods

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Prisma Client Extension - Instance Methods

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.

Caveats

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.

How to use

Prerequisites

1. Download example & install dependencies

Clone this repository:

git clone [email protected]:sbking/prisma-client-extensions.git

Install dependencies:

cd instance-methods
npm install

2. Create an SQLite database and run migrations

Run the following command. An SQLite database will be created automatically:

npx prisma migrate deploy

3. Run the dev script

To run the script.ts file, run the following command:

npm run dev