0:00 All right, so now that we have the port available for our 0:03 product repository, 0:04 it's time to create an adapter for the port. 0:07 Now, in a clean architecture, the adapter is the class 0:11 that then implements the port. So in this case, we have our 0:15 interface for the product repository. 0:18 We're gonna create multiple adapters to this port, and that will be the 0:21 underlying implementation of the repository itself. 0:26 So we'll have one for Drizzle and one for MongoDB. 0:29 So in order to start implementing this, inside of our product directory, 0:33 let's create a new folder. 0:36 I'm gonna call this infrastructure, and inside of infrastructure, I'm 0:39 gonna keep my adapter's directory. 0:42 And finally, inside of adapters, we can now create our first 0:46 adapter, our Drizzle ORM adapter. 0:49 So I'll call this the drizzleProduct.repository. 0:53 And let's go ahead and now set up this class, 0:55 which will be injectable so that we 0:56 can inject it at runtime into other NestJS services. 1:00 And so we'll export class DrizzleProductRepository. 1:04 This will now implement our product repository, 1:09 which is pointing to our product repository port. 1:12 So now we can see that the product repository 1:14 is complaining because, of course, we 1:15 haven't implemented the required methods yet. 1:19 So let's go ahead and see how we can implement these methods 1:21 inside of the new 1:22 DrizzleProductRepository. To start, we wanna go ahead and... 1:27 Remember, we set up our Drizzle provider in previous 1:30 lectures to connect to our underlying Postgres database. 1:35 So make sure you have this running 1:37 in a separate tab with our Docker Compose up. 1:39 And now we wanna actually use this provider. 1:41 So remember, we set this up in a Drizzle module 1:45 with the Drizzle provider here and exported it. 1:47 So now we can actually inject this inside of our 1:50 DrizzleProductRepository. And so we're gonna need this to actually
The rest of the transcript is for members.
Sign in